|
|
back to board... Stack overflow... ? C++ Posted by Ingy 21 May 2014 14:51 #include <cmath> #include <iomanip> #include <iostream> using namespace std; int main () { double number [100000]; int i=0; while ( ! cin.eof()) { cin >> number [i]; i++; } for( int j=i-1; j>=0; j--) { cout<< setprecision (4) << sqrt(number[j])<<endl; } return 0; } here's my program but I don't know what's wrong.. when i put the number of elements of the array to 140000 it says "stack overflow", when i put 10000 it says wrong answer. Re: ... Stack overflow... ? C++ All local variables are allocated in stack. Array "number"[] is local, because it is described in function "main". Standard size of stack is 1 MB, size of double variable is 8 bytes. So it isn't enough space to allocate all array with 140000 elements. You should increase stack size. http://acm.timus.ru/help.aspx?topic=cpp #pragma comment(linker, "/STACK:16777216") Edited by author 22.05.2014 15:07 |
|
|