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 1226. esreveR redrO

Crash!
Posted by Evil Cheater 6 Nov 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!
Posted by Илья Гофман (Ilya Gofman) 13 Nov 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!
Posted by Evil Cheater 14 Nov 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?
Posted by Evil Cheater 14 Nov 2002 22:49
Fixed that but now I get WA. Can you tell me a test for which my
program doesn't work.


   Thanks!