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 1197. Lonesome Knight

THAT EASY(PASCAL)
Posted by zsldg2005 13 Feb 2008 08:18
program p1197;
var
  st:string;
  n,i:byte;
procedure sort1;
begin
  if (st[2]='1') or (st[2]='8')
  then begin writeln(2); exit; end;
  if (st[2]='2') or (st[2]='7')
  then begin writeln(3); exit; end;
  writeln(4);
  exit;
end;
procedure sort2;
begin
  if (st[2]='1') or (st[2]='8')
  then begin writeln(3); exit; end;
  if (st[2]='2') or (st[2]='7')
  then begin writeln(4); exit; end;
  writeln(6);
  exit;
end;
procedure sort3;
begin
  if (st[2]='1') or (st[2]='8')
  then begin writeln(4); exit; end;
  if (st[2]='2') or (st[2]='7')
  then begin writeln(6); exit; end;
  writeln(8);
  exit;
end;
begin
  readln(n);
  for i:=1 to n do
  begin
    readln(st);
    if (st[1]='a') or (st[1]='h')
    then begin sort1; end;
    if (st[1]='b') or (st[1]='g')
    then begin sort2; end;
    if (st[1]='c') or (st[1]='d') or (st[1]='e') or (st[1]='f')
    then begin sort3; end;
  end;
end.