|
|
back to boardWrong answer(please help with input array) Code: C/C++ #include <iostream> #include <math.h> #include <stdio.h> int main() { const int N=10000; double a[N]; long count=0,i; while (std::cin>>a[i]) { std::cin>>a[i]; count++;} printf("\n"); for(i=count-1;i>=0;i--) printf("%25.4lf\n",sqrt(a[i])); return 0; } Question:How to insert an array to provide input before the end of the border Please help, I`am beginner=( Thanks. Re: Wrong answer(please help with input array) 1. N can be maximum 131072 so adjust N accordingly. 2. Move double A[N] outside the main function as it exceeds the stack memory. 3. Initialize i and increase it after reading a[i]. 4. You have two statements of cin >> a[i]. Delete the second one. 5. Eliminate %25.4 from the printing, leave just %.4 You'll get AC. Edited by author 08.09.2011 20:29 Re: Wrong answer(please help with input array) Posted by MaximG. 25 Oct 2011 20:10 could you tell me , why 131072? Re: Wrong answer(please help with input array) The statement say that the input size does not exceed 256KB that means 262144 bytes. The "worst" input should be "d d d" etc (one digit number, one space) so there can be maximum of INPUT/2 numbers. Re: Wrong answer(please help with input array) Posted by MaximG. 25 Oct 2011 22:19 2 morbidel: thank you very much! |
|
|