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 1094. E-screen

Where is my mistake?????????
Posted by AmBush 20 Jun 2002 01:54
I always got "Crach" answer! Can anybody help me, please?!

Here is my program....

{my e-mail is: limak8@wp.pl}

var
tab: array [0..10000] of char;
max,i: longint;
c: char;

begin
max:=80;
for i:=1 to 80 do tab[i]:=' ';

i:=1;
repeat

read(c);
if c='<' then begin i:=i-1 end else
if c='>' then i:=i+1 else
if c=#13 then else begin
                   tab[i]:=c;
                   i:=i+1;
                   end;

If i<=0 then i:=1 else if i>max then max:=i;

until c=#13;

i:=0;
repeat
i:=i+1;
write(tab[i]);
until i=max;

end.
Re: Where is my mistake?????????
Posted by Oscar 5 Jul 2002 00:12
You need to put limits on this part:

if c='<' then begin i:=i-1 end else

something like this:

if c='<' then if i>0 then inc(i);

that may be the problem.
Re: Where is my mistake?????????
Posted by Oscar 5 Jul 2002 00:12
You need to put limits on this part:

if c='<' then begin i:=i-1 end else

something like this:

if c='<' then if i>0 then dec(i);

that may be the problem.