## HELP WITH PROBLEM 10196

Write here if you have problems with your Pascal source code

Moderator: Board moderators

### HELP WITH PROBLEM 10196

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]
AllanLin
New poster

Posts: 8
Joined: Thu Jun 26, 2003 3:38 am

try remove uses crt; and clrscr;
it seems that it's not necessary as the question is not asking you to output to screen

i dunno if they allow u to use crt...
raymond85
New poster

Posts: 21
Joined: Tue Jul 01, 2003 9:26 am
Location: Hong Kong

Yes. Cut the "crt" part and you'll no longer get CE (but you'll get WA)
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
Observer
Guru

Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Yes friend. Cut the "Uses Crt" and "clrscr"
Alberto
New poster

Posts: 4
Joined: Fri May 20, 2005 5:15 pm
Location: La Paz - Bolivia

Return to Pascal

### Who is online

Users browsing this forum: No registered users and 1 guest