主题:一个不知道错在哪里的错误!大虾请进!
各位大虾:
本人编写了一个程序,可是有一个错误,怎么也看不出是哪出错了。各位大虾帮帮忙!
program game;
var
a:array[1..4] of integer;
x:array[1..4] of integer;
n,m,b,w,i,c:integer;
x1:set of 0..9;
begin
fillchar(a,sizeof(a),0);
i:=0;
b:=0;
w:=0;
randomize;
for n:=1 to 4 do
x[n]:=random(10);
for c:=1 to 10 do
begin
i:=i+1;
if i=10 then write('Game over') else
writeln('input your number:');
for m:=1 to 4 do
begin
read(a[m]);
end;
case a[1] of
x[1]:b:=b+1; 错误: cannot evaluate this expression
x[2]:w:=w+1;
x[3]:w:=w+1;
x[4]:w:=w+1;
end;
case a[2] of
x[2]:b:=b+1;
x[1]:w:=w+1;
x[3]:w:=w+1;
x[4]:w:=w+1;
end;
case a[3] of
x[3]:b:=b+1;
x[1]:w:=w+1;
x[2]:w:=w+1;
x[4]:w:=w+1;
end;
case a[4] of
x[4]:b:=b+1;
x[1]:w:=w+1;
x[2]:w:=w+1;
x[3]:w:=w+1;
end;
if a[1]=x[1],a[2]=x[2],a[3]=x[3],a[4]=x[4] then
writeln('comgratulation to you!') else
writeln('*:'b,'@:',w);
end;
而且本人已用变量代替数组试过也不行!
但改用IF语句就行了!