unit Unit2;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,StdCtrls;type
TIntArray=array of Integer;
TForm2 = class(TForm)
ListBox1: TListBox;
Label1: TLabel;
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
procedure ShowIntArray(IA: TIntArray);
{ Private declarations }
public
{ Public declarations }
end;var
Form2: TForm2;implementation{$R *.dfm}Function GetSqrArray(num:Integer):TIntArray;
var IA:TIntArray;
i:Integer;
begin
SetLength(IA,num);//设置数组个数
for i:=0 to num-1 do
IA[i]:=SQR(i)
Result:=IA;//[Error] Unit2.pas(38): Missing operator or semicolon
end;procedure TForm2.ShowIntArray(IA: TIntArray);
var i:Integer;
begin
ListBox1.Items.Clear;
for i:=Low(IA) to High(IA) do
begin
ListBox1.Items.Add(IntToStr(i)+'的2次方='+IntToStr(IA[i]));
end;
end;procedure TForm2.Button1Click(Sender: TObject);
var IB:TIntArray;begin
IB:=GetSqrArray(StrToInt(Edit1.Text));
ShowIntArray(IB);
end;
end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,StdCtrls;type
TIntArray=array of Integer;
TForm2 = class(TForm)
ListBox1: TListBox;
Label1: TLabel;
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
procedure ShowIntArray(IA: TIntArray);
{ Private declarations }
public
{ Public declarations }
end;var
Form2: TForm2;implementation{$R *.dfm}Function GetSqrArray(num:Integer):TIntArray;
var IA:TIntArray;
i:Integer;
begin
SetLength(IA,num);//设置数组个数
for i:=0 to num-1 do
IA[i]:=SQR(i)
Result:=IA;//[Error] Unit2.pas(38): Missing operator or semicolon
end;procedure TForm2.ShowIntArray(IA: TIntArray);
var i:Integer;
begin
ListBox1.Items.Clear;
for i:=Low(IA) to High(IA) do
begin
ListBox1.Items.Add(IntToStr(i)+'的2次方='+IntToStr(IA[i]));
end;
end;procedure TForm2.Button1Click(Sender: TObject);
var IB:TIntArray;begin
IB:=GetSqrArray(StrToInt(Edit1.Text));
ShowIntArray(IB);
end;
end.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货