pascal错误207

来源:百度知道 编辑:UC知道 时间:2024/05/31 09:53:37
程序如下:
var s1,s2,s3:array[1..59] of real;
xh,fs,i:integer;
max:real;
begin
max:=0;
fillchar(s1,sizeof(s1),25);
writeln('扣分');
while xh<>60 do begin
readln(xh,fs);
s1[xh]:=s1[xh]-fs;
end;
writeln('加分');
while xh<>60 do begin
readln(xh,fs);
s1[xh]:=s1[xh]+fs;
end;
for i:=1 to 59 do if s1[i]>max then max:=s1[i];
for i:=1 to 59 do begin
s2[i]:=s1[i]/max*5;
s3[i]:=round(s2[i]*2);
end;
for i:=1 to 59 do write(s3[i]/2:4:1);
while true do I:=i+1;
end.

输入两个60跳过while没事,一旦有输入就报错207.

fillchar的赋值错误,你可以单步跟踪一下,fillchar(s1,sizeof(s1),25); 后s1是很诡异的浮点值,而且在
你要给s1 fillchar的值是25的话不是这样赋的
而且输入60的话数组会直接越界。。。
你的数组开的上限到59。。。运行60必然得出错。。。

207:无效浮点运算
具体错误自己找吧 :)