把它在FORM1的画布上打出来,可以看的更清楚一些!
procedure TForm1.Button1Click(Sender: TObject);
var
data:array of integer;
i,Len:integer;
temp:integer;
begin
button1.Enabled:=false;
Len:=strtoint(inputbox('输入数字','请输入数组的长度',''));
setlength(data,len);
for i:=0 to len-1 do
begin
data[i]:=10+i;
form1.Canvas.TextOut(40,40+20*i,'data['+inttostr(i)+']: '+inttostr(data[i]));
end;
i:=0;
while i<len-1 do
begin
temp:=data[i];
data[i]:=data[i+1];
data[i+1]:=temp;
i:=i+2;
end;
for i:=0 to len-1 do
form1.Canvas.TextOut(150,40+20*i,'data['+inttostr(i)+']: '+inttostr(data[i]));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
form1.Refresh;
button1.Enabled:=true;
end;