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 (access violation) №9
Posted by Iosif inf-10 28 Nov 2009 18:50
Program N1226;
var
  T:Array[1..10000] of char;

  S:string;
  i,j,Len:integer;
BEGIN
    i:=0;
    while (not eof) do
      begin
        inc(i);
        read(T[i]);
      end;

    Len:=i;
   T[i+1]:='!';
    i:=1;  S:='';
    while (i<=Len+1) do
          if (T[i] in ['a'..'z','A'..'Z'])
          then begin
          S:=S+T[i];
          inc(i)
          end
          else begin

          for j:=length(s) downto 1 do write(s[j]);
          S:='';

          if i<=Len then
          write(T[i]);
          inc(i);
          end;
END.

Crash (access violation)    №9

!!!!!!!!!!!!!!!!!!!
BUT When I add:
 "W:array [1..255] of char;"


Program N1226;
var
  T:Array[1..10000] of char;
  W:array [1..255] of char; //<----------Accepted
  S:string;
  i,j,Len:integer;
BEGIN
    i:=0;
    while (not eof) do
      begin
        inc(i);
        read(T[i]);
      end;

    Len:=i;
   T[i+1]:='!';
    i:=1;  S:='';
    while (i<=Len+1) do
          if (T[i] in ['a'..'z','A'..'Z'])
          then begin
          S:=S+T[i];
          inc(i)
          end
          else begin

          for j:=length(s) downto 1 do write(s[j]);
          S:='';

          if i<=Len then
          write(T[i]);
          inc(i);
          end;
END.

Accepted!
Why???

Edited by author 28.11.2009 18:51
Re: Crash (access violation) №9
Posted by unlucky [Vologda SPU] 28 Nov 2009 20:14
Yep.. it is strange.
Array W is not used at second program and codes are the same