|
|
вернуться в форумgetting a runtime error (stackoverflow) #include<iostream> #include<math.h> int main() { using namespace std; int i; float r,a[128*64]; unsigned long long n,j,k; for(i=0;i<n;i++) cin>>a[i]; j=n-1; for(k=j;k>=0;k--) { r=sqrt(a[k]); cout<<r<<"\n"; } return 0; } Re: getting a runtime error (stackoverflow) You should try to increase the size of your array and perhaps use a double array over float. Slowpokes to the rescue - Re: getting a runtime error (stackoverflow) > A size of the input stream does not exceed 256 KB Minimum number of chars per number is 2 - "0 ". So you have to receive up to 128 K numbers. Your array is about 8 K numbers. You shouldn't allocate such big arrays on stack. Use dynamic allocation or std::vector. And another note. > unsigned long long n,j,k; > for(i=0;i<n;i++) > cin>>a[i]; How many times will this for iterate? Why? Edited by author 15.12.2015 21:02 Re: getting a runtime error (stackoverflow) It's preferable to use a double precision floating point type over a single float. n is not given in the input data. I recommend to use std::vector to alloc it: vector <double> input; double aux; while(cin>>aux) input.push_back(aux); |
|
|