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

Why WA?
Posted by Avanesov 28 Feb 2002 17:10
Neither first my program, nor second are right.
Why??!
Here they are:

program first;
const
   ks : set of char = ['>','<','a'..'z','A'..'Z','0'..'9',';',':','-
','!','?','.',',',' '];
var
  ch : char;
  pos : byte;
  res : string[80];
begin
  res:='';
  for pos:=1 to 80 do res:=res+' ';
  pos:=1;
  ch:=#0;
  while (ch<>#26) do
  begin
  read(ch);
  if ch=#26 then break;
  if not (ch in ks) then continue;

  if ch='>' then
   begin
    if pos=80 then pos:=1;
   end
  else
  if ch='<' then
   begin
    if pos<>1 then dec(pos);
   end
  else
  begin
   res[pos]:=ch;
   if pos=79 then pos:=1 else
   inc(pos);
  end

  end;
  Writeln(res);
end.

program second;
const
   ks : set of char = ['>','<','a'..'z','A'..'Z','0'..'9',';',':','-
','!','?','.',',',' '];
var
  ch : char;
  pos : byte;
  res : string[80];
begin
  res:='';
  for pos:=1 to 80 do res:=res+' ';
  pos:=1;
  ch:=#0;
  while (ch<>#26) do
  begin
  read(ch);
  if ch=#26 then break;
  if not (ch in ks) then continue;

  if ch='>' then
   begin
    if pos=80 then pos:=1;
   end
  else
  if ch='<' then
   begin
    if pos<>1 then dec(pos);
   end
  else
  if pos = 80 then
  begin
   res[pos]:=ch;
   pos:=1;
  end
  else
  begin
   res[pos]:=ch;
   inc(pos);
  end

  end;
  Writeln(res);
end.

Please, help!
Sorry!! I've found mistake! Sorry!
Posted by Avanesov 28 Feb 2002 17:23
program p1094;
const
   ks : set of char = ['>','<','a'..'z','A'..'Z','0'..'9',';',':','-
','!','?','.',',',' '];
var
  ch : char;
  pos : byte;
  res : string[80];
begin
  res:='';
  for pos:=1 to 80 do res:=res+' ';
  pos:=1;
  ch:=#0;
  while (ch<>#26) do
  begin
  read(ch);
  if ch=#26 then break;
  if not (ch in ks) then continue;

  if ch='>' then
   begin
    if pos=80 then pos:=1
    else inc(pos);
   end
  else
  if ch='<' then
   begin
    if pos<>1 then dec(pos);
   end
  else
  if pos = 80 then
  begin
   res[pos]:=ch;
   pos:=1;
  end
  else
  begin
   res[pos]:=ch;
   inc(pos);
  end

  end;
  Writeln(res);
end.