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 with my code?
Posted by Neolisk 9 Jul 2007 20:29
#include <stdio.h>
#include <math.h>
void main()
{
    double n;
    while(scanf("%lf",&n) != EOF)
        printf("%.4lf\n",sqrt(n));
}
It gets WA on the 1st test, although it should work (in theory). The problem is that I can't check whether it reads as it should just because I don't know how to put EOF symbol at the end of the input manually. Does anyone know how it should be done?

Edited by author 09.07.2007 20:30
Re: What's wrong with my code?
Posted by CHIDEMYAN SERGEY 9 Jul 2007 23:32
You must output answers in reverse order!Good luck!
Maybe it'll help you:
[code deleted]

Edited by author 09.07.2007 23:32

Edited by author 09.07.2007 23:51

Edited by author 10.07.2007 00:28

Edited by author 12.07.2007 03:12
Re: What's wrong with my code?
Posted by Neolisk 10 Jul 2007 16:13
Thank you very much! How could I miss that... Probably because I'm not that good at stream handling and focused my mind on finding other ways to read/write streams in C/C++.

Yet this code gets CE on submit, but it doesn't on my PC. Is it because those written here don't count? :))
Re: What's wrong with my code?
Posted by CHIDEMYAN SERGEY 10 Jul 2007 23:57
I write this program on C++.Try to send it on C++ && you'll get AC.I create dynamic array & maybe in C
it gets CE.Good luck!

Edited by author 10.07.2007 23:59
Re: What's wrong with my code?
Posted by Neolisk 24 Jul 2007 23:52
Unfortunately I'm not that good at C++ console streams. How do I check the end of output?

(cin >> a) != EOF

Is that correct?
Re: What's wrong with my code?
Posted by M@STeR.SoBG 25 Jul 2007 06:11
You can check the end of output in such a way:

while( cin >> a )
{
//--your code---
}