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

Help! Why my program got WA at test4??? I didn't know!
Posted by Tang RZ 7 Jun 2004 11:46
This is my program:
var
  a:array [1..80] of char;
  hand:integer;

procedure work(ch:char);
begin
  if ch='>' then
    begin
      inc(hand);
      if hand>=80 then hand:=1;
    end
    else if ch='<' then
      begin
        dec(hand);
        if hand<=1 then hand:=1;
      end
      else if (ch>='a')and(ch<='z')or(ch>='A')and(ch<='Z') then
        begin
          a[hand]:=ch;
          inc(hand);
          if hand>=80 then hand:=1;
        end
        else
          begin
            a[hand]:=ch;
            inc(hand);
            if hand<1 then hand:=1;
          end;
end;

procedure init;
var
  ch:char;
begin
  hand:=1;
  fillchar(a,sizeof(a),' ');
  repeat
    read(ch);
    work(ch);
  until eof;
end;

procedure print;
var
  i:integer;
begin
  for i:=1 to 80 do
    write(a[i]);
  writeln;
end;

begin
  init;
  print;
end.