问题代码如下: 点击运行可以,但输入完数字后点BUTTON后提示出错 不能接着运行这是为什么
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Memo1: TMemo;
Label1: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var a:array of integer;
t,m,i:integer;
begin
setlength(a,6); //设置含7个元素的数组
for i:=0 to 6 do
a[i]:=strtoint(memo1.Lines[i]); //从MEMO1中读取元素
for i:=0 to 5 do
if a[i]>a[i+1] then //7个数比较大小,最大的为a[6];
begin
t:=a[i];a[i]:=a[i+1];a[i+1]:=t;
end;
memo1.lines.add('去掉一个最高分:'+inttostr(a[6])); //输出最大数
for i:=5 downto 1 do
if a[i]<a[i-1] then
begin
t:=a[i-1];a[i]:=a[i-1];a[i-1]:=t; //前面6个数比较大小,最小的为a[0]
end;
m:=a[1]+a[2]+a[3]+a[4]+a[5]+a[6]; //去掉以最大小后的总和
memo1.lines.add('去掉一个最低分:'+inttostr(a[0]));
memo1.lines.add('选手最后得分'+inttostr(m));end;end.
in module 'projiect2.exe' write to address 00425838
简单说就是程序异常 但别的代码运行一样是可以的 应该是这个代码出错了