Dear Programmers:
WHY DO I HAVE A COMPLING ERROR.. PLEASE HELP ME
[pascal]
uses crt;
const
ndx : array [1..8] of integer = (-1,+1,+2,+2,-1,+1,-2,-2);
ndy : array [1..8] of integer = (+2,+2,+1,-1,-2,-2,+1,-1);
kdx : array [1..8] of integer = (+1,-1,+0,+0,+1,+1,-1,-1);
kdy : array [1..8] of integer = (+1,-1,+0,+0,+1,-1,+1,-1);
rdx : array [1..4] of integer = (+1,-1,+0,+0);
rdy : array [1..4] of integer = (+0,+0,+1,-1);
bdx : array [1..4] of integer = (+1,+1,-1,-1);
bdy : array [1..4] of integer = (+1,-1,+1,-1);
var
w,b : array [-1..10,-1..10] of char;
wcheck,bcheck : boolean;
function input:integer;
var i,j : integer;
king: integer;
ch : char;
begin
king := 0;
for i:=1 to 8 do
begin
for j:=1 to 8 do
begin
read(ch);
w[i,j]:='.';
b[i,j]:='.';
if( ch in [ 'a'..'z' ] )then
begin
w[i,j] := ch;
b[i,j] := '*';
if( ch = 'k')then
begin
b[i,j] := '#';
inc(king);
end;
end
else if( ch in [ 'A'..'Z' ] )then
begin
b[i,j] := ch;
w[i,j] := '*';
if( ch = 'K')then
begin
w[i,j] := '#';
inc(king);
end;
end;
end;
readln;
end;
readln;
input:=king;
end;
var
i,j,k : integer;
x,y : integer;
count : integer;
begin
clrscr;
count :=0;
while(input=2)do
begin
inc(count);
bcheck := false;
wcheck := false;
for i:=1 to 8 do
for j:=1 to 8 do
if( w[i,j] = '#' )then
begin
if( w[i+1,j-1] = 'p' ) or
( w[i+1,j+1] = 'p' ) then
wcheck := true;
for k:=1 to 8 do
if( w[i+kdx[k],j+kdy[k]] = 'k' )then
wcheck := true;
for k:=1 to 8 do
if( w[i+ndx[k],j+ndy[k]] = 'n' )then
wcheck := true;
for k:=1 to 4 do
begin
x := i; y := j;
repeat x:=x+rdx[k]; y:=y+rdx[k];
until (w[x,y]<>'.');
if( w[x,y] in ['r','q'])then
wcheck := true;
end;
for k:=1 to 4 do
begin
x := i; y := j;
repeat x:=x+bdx[k]; y:=y+bdx[k];
until (w[x,y]<>'.');
if( w[x,y] in ['b','q'])then
wcheck := true;
end;
end;
for i:=1 to 8 do
for j:=1 to 8 do
if( b[i,j] = '#' )then
begin
if( b[i-1,j-1] = 'P' ) or
( b[i-1,j+1] = 'P' ) then
bcheck := true;
for k:=1 to 8 do
if( b[i+kdx[k],j+kdy[k]] = 'K')then
bcheck := true;
for k:=1 to 8 do
if( b[i+ndx[k],j+ndy[k]] = 'N')then
bcheck := true;
for k:=1 to 4 do
begin
x := i; y := j;
repeat x:=x+rdx[k]; y:=y+rdx[k];
until (b[x,y]<>'.');
if( b[x,y] in ['R','Q'])then
bcheck := true;
end;
for k:=1 to 4 do
begin
x := i; y := j;
repeat x:=x+bdx[k]; y:=y+bdx[k];
until (b[x,y]<>'.');
if( b[x,y] in ['B','Q'])then
bcheck := true;
end;
end;
write('Game #',count,': ');
if( bcheck )then writeln('black king is in check.')
else if( wcheck )then writeln('white king is in check.')
else writeln('no king is in check.');
end;
end.
[/pascal]
