改錯(cuò)題
改錯(cuò)題(共4道)
1. 指出下列代碼錯(cuò)誤并說明原因:
Var
I:Integer;(超出范圍)
L:Long;
Begin
L:=32768;
I:=L;
End.
2. 指出下列代碼錯(cuò)誤并說明原因:
if n>37.5 then
AmountEarned:=(n-37.5)*HourlyRate*1.5+37.5*HourlyRate; (沒有定義n, AmountEarned, HourlyRate)
else
AmountEarned:= n*HourlyRate;
3. 指出下列代碼錯(cuò)誤并說明原因:
while (total<max) and (sum<=max) and (sum<total)
do statement1;
4. 指出下列代碼錯(cuò)誤并說明原因:
procedure Tform1.TestBtnClick(Sender:Tobject);
var z,y,x:integer;
begin
x:=100;
y:=0;
try
z:=x div y;
except
on EdivByZero
do begin
z:=-1;
MessageDlg(\'Z\'+IntToStr(z),mtInformation,[mbOK],0);
end
End;
【改錯(cuò)題】相關(guān)文章: