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

What's wrong in my code?
Posted by vasya 25 Jul 2007 19:57
#include <iostream>
#include <math.h>
using namespace std;

int main()
{

long b=-1,c;
long A[10000];

while(cin>>c)
{
    b=b+1;
    A[b-1]=c;
}

for(int i=b-1;i>=0;i--)
{
    printf(".4ld\n",sqrt(double(A[i])));
}


return 0;
}

Edited by author 25.07.2007 20:00
Re: What's wrong in my code?
Posted by Mace(Lviv Polytechniс NU) 25 Jul 2007 22:26
You must wrote "for(int i=b;i>=0;i--)" or initialize b as "0". Your code dont process last inputted number.
P.S. And, by the way, you can write "b++" instead of "b=b+1" ;) This is C++, enjoy it =)