|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
最大值的下标是从右往左拉~!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
edt1: TEdit;
btn1: TButton;
lbl1: TLabel;
lbl2: TLabel;
edt2: TEdit;
edt3: TEdit;
procedure btn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
var
rad_num: array[1..10] of Integer;
i,j:Integer;
max,max_1:Integer;
begin
edt1.Text:='';
edt2.Text:='';
edt3.Text:='';
for i :=1 to 10 do
begin
Randomize;
rad_num[i] := 10 + Random(90) ;
edt1.Text:=IntToStr(rad_num[i]) + ','+ edt1.Text;
end;
edt1.Text:= Copy(edt1.Text, 1, Length(edt1.Text) - 1);
max:=rad_num[1];
max_1:=1;
for i:= 2 to 10 do
begin
if (max < rad_num[i]) then
begin
max:= rad_num[i] ;
max_1:=i;
end;
end;
edt2.Text:=IntToStr(max);
edt3.Text:=IntToStr(max_1);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(edt1.Handle,GWL_STYLE,GetWindowLong(edt1.Handle,GWL_STYLE)+ES_CENTER);
edt1.Refresh;
//以上代码是光标定位在中间
end;
end.
|
|