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

I got WA1! Please help me!
Posted by Zyxel_Sasha 14 Nov 2005 14:29
{WA1}
program Sol;

{$APPTYPE CONSOLE}
{$O-}
uses
  SysUtils;
var ch:char;
    screen:array[1..80]of char;
    i,j,cx,cy:integer;
begin
  assign(input,'input.txt');
  reset(input);
  assign(output,'output.txt');
  rewrite(output);
  read(ch);
  cx:=1;
  cy:=1;
  fillchar(screen,sizeof(screen),'#');
  while not(eof(input)) do
  begin
    case ch of
    '<':
    begin
      dec(cx);
      if cx<1 then cx:=1
    end;
    '>':
    begin
      inc(cx);
      if cx>80 then cx:=1;
    end;
    #10,#13:readln;
    else
        screen[cx]:=ch;
        inc(cx);
        if cx>80 then cx:=1;
    end;
    read(ch);
  end;
  for j:=1 to 80 do
  if screen[j]='#' then write('*')
  else
    write(screen[j]);
  close(input);
  close(output);
end.