谁能帮忙看看这个Delphi程序哪里错,怎么运行不了?
procedure TForm1.Button1Click(Sender: TObject); begin sum:=0; i:=1; repeat sum:=sum+i; i:=i+1; until i >100; showmessage(inttostr); end; end.
procedure TForm1.Button1Click(Sender: TObject); begin sum:=0; i:=1; repeat sum:=sum+i; i:=i+1; until i >100; showmessage(inttostr); end; end.
答案:procedure TForm1.Button1Click(Sender: TObject);
var
sum,i:integer;//错误1:没有定义变量
begin
sum:=0;
i:=1;
repeat
sum:=sum+i;
i:=i+1;
until i >100;
showmessage(inttostr(sum));//错误2:inttostr函数没有参数
end;
其他:下面一行有错,参数不对:
showmessage(inttostr);
应该修改为:
showmessage(inttostr(sum));