ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1001. Reverse Root

C++ Crash (stack overflow)
Posted by Grillepitch 21 Jul 2011 01:27
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main()
{
        long double array[128*1024];
    long double x = 0;
    int k = 0;
    while ( cin >> x )
    {
        array[k] = sqrt(x);
        ++k;
    }
    for ( int i = k-1; i >= 0; --i )
        cout << fixed << setprecision(4) << array[i] << endl;
    return 0;
}
Re: C++ Crash (stack overflow)
Posted by hatred 21 Jul 2011 01:52
try to define array in global namespace (not in main())
Re: C++ Crash (stack overflow)
Posted by Grillepitch 21 Jul 2011 01:57
Thank you very much !