ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1001. Обратный корень

What's wrong with my code?
Послано Neolisk 9 июл 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?
Послано CHIDEMYAN SERGEY 9 июл 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?
Послано Neolisk 10 июл 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?
Послано CHIDEMYAN SERGEY 10 июл 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?
Послано Neolisk 24 июл 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?
Послано M@STeR.SoBG 25 июл 2007 06:11
You can check the end of output in such a way:

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