|
|
вернуться в форумCrash! 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! 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! 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? Fixed that but now I get WA. Can you tell me a test for which my program doesn't work. Thanks! |
|
|