|
|
back to boardCan anybody help me, please? This code seems to solve the problem on my computer, but it I got WA on test#3! I've been trying for some hours to improve it. But I think I've already tried everything I know (which is certainly not too much!) Please, can you tell me what's wrong here? #include<iostream> #include<iomanip> #include<cmath> #include<cstdlib> using namespace std; int main() { const int size = 128000; int counter=0, max; double x; double* array = new double[size]; double* ptr = array;
cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(4); while(1) { cin>>x; if(cin.eof())break; counter++; (*ptr)=sqrt(x); if(counter < size) ptr++; } if(counter < size) ptr--; max = counter; for(counter=max;counter > 0;counter--) { cout<<*ptr<<endl; ptr--; }
return 0; } |
|
|