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

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

bidakung How java deal with these input? [4] // Задача 1001. Обратный корень 27 янв 2011 10:54
When i using BufferedReader of java with readLine function.
It will read for 'N' lines that 'N' is specific.

And when input is not specific of line, how should i deal with the input? How java knows the input string is ended?

Sorry for bad english,

bidakung
tagetes Re: How java deal with these input? [2] // Задача 1001. Обратный корень 23 апр 2011 15:29
my idea:

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      ..........
      try{
        while(true){
          .....in.readLine().......
        }
      }
      catch(Exception e){}
    ...........


the end of read by Exception.

Edited by author 23.04.2011 17:40
you can not catch exceptions - this is a bug
You can use StringTokenizer by reading the line as string and then dividing it into tokens.
        Scanner inputReader = new Scanner(System.in);


        while(inputReader.hasNext()) {
            long n = inputReader.nextLong();

        }



Edited by author 29.10.2011 02:14

Edited by author 29.10.2011 02:19