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

My Solution Here:
Posted by Destiny 12 Nov 2002 07:03
program lonesome;
const
 dx:array[1..8]of integer
    =(1,2,2,1,-1,-2,-2,-1);
 dy:array[1..8]of integer
    =(2,1,-1,-2,-2,-1,1,2);
var
 strr:string[2];
 num,n,i,x,y:integer;
procedure solve(x,y:integer);
var
 i,tempx,tempy:integer;
begin
 for i:=1 to 8 do
  begin
   tempx:=x+dx[i];
   tempy:=y+dy[i];
   if (tempx>=1) and (tempx<=8) then
    if (tempy>=1) and (tempy<=8) then
       inc(num);
  end;
end;
begin
 readln(n);
 for i:=1 to n do
  begin
   readln(strr);
   x:=ord(strr[1])-ord('a')+1;
   y:=ord(strr[2])-ord('0');
   num:=0;
   solve(x,y);
   writeln(num);
  end;
end.