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

Wrong answer
Posted by ZiDo 15 Sep 2012 20:44
Pleas Assist=)
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main()
{

double arr[32768];
int i=0;
double value=0;
while(cin>>value)
{
    if (value>0)
    {
        arr[i++]=sqrt(value);
        value=0;
    }
        else break;

}
cout<<setprecision(4)<<fixed;
while(i--)
{
    cout <<arr[i]<<endl;
}
system("pause");

}

Edited by author 15.09.2012 23:36
Re: Wrong answer
Posted by Smilodon_am [Obninsk INPE] 17 Sep 2012 11:24
First of all the amount of numbers are about 129000 but not 32768 as you have written.
Re: Wrong answer
Posted by Bogatyr 18 Sep 2012 13:40
Right, but if you're using C++ why not use a dynamic container like std::vector.   If you don't know STL it's worth learning at least the STL containers.  vector, map, and set in particular are immensely useful and bring C++ up to "higher" level language status than C++ without them.   They're especially useful when you don't know the input limits beforehand because they grow automatically.

Edited by author 18.09.2012 13:41
Re: Wrong answer
Posted by Sunnat 3 Oct 2012 00:15
#include<iostream>
#include<math.h>
using namespace std;
#pragma comment(linker, "/STACK:2000000")
void worc(){
   double k;
   if(scanf("%lf",&k)!=EOF){
     worc();
     printf("%.4lf\n",sqrt(k));
   }
}
int main()
{
   worc();
   return 0;
}