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

Обсуждение задачи 1226. йынтарбО кодяроп

Crash!
Послано Evil Cheater 6 ноя 2002 20:31
 HI!

   Why does my program crashes? I thought it was the "downto" but I
changed it and it still won't run, I also tried making the array
bigger and checking if n=0 before using the "for" but nothing seemed
to work.

  Any help appreciated!


Var
   ch: char;
   i,n: integer;
   a: array [1..255] of char;

Begin
      Repeat
            read(input,ch);
            if (ch in ['a'..'z']) or
               (ch in ['A'..'Z']) then begin
                                       Inc(n);
                                       a[n]:= ch;
                                       end
                                  else begin
                                       for n:= n downto 1 do
                                           write(output,a[n]);
                                       n:= 0;
                                       write(output,ch);
                                       end;
            until (eof(input));
End.
Re: Crash!
Послано Илья Гофман (Ilya Gofman) 13 ноя 2002 18:13
I think you shouldn't use the handle "input", because the Judge
System conciders this like reading 2 different variables, one of
which is not declared(input). It will automatically read from the
input. Always(in TP and Delphi).
So, instead of read(input,x) you should use read(x). the same is
with the output and eof.
Moreover, you need to initialize all the variables before working
with them, because the initial value can be -1234 or 1234 - any:)
but NOT 0- so add a line 'n:=0' in the very beginning of your
program.
 Good Luck!
Thanks!
Послано Evil Cheater 14 ноя 2002 22:36
  The "read(input,x)" part is OK. Actually, I send all my problems
like that. The problem was the initialization (I have to be a little
more careful). Thanks for your help!

WA, can you help me?
Послано Evil Cheater 14 ноя 2002 22:49
Fixed that but now I get WA. Can you tell me a test for which my
program doesn't work.


   Thanks!