星爷 发表于 2013-9-20 20:41:28

刚学的Dephi 大家帮忙看看我的代码哪里有问题!

最大值的下标是从右往左拉~!

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 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 := 10 + Random(90) ;
    edt1.Text:=IntToStr(rad_num) + ','+ edt1.Text;
end;
edt1.Text:= Copy(edt1.Text, 1, Length(edt1.Text) - 1);
max:=rad_num;
max_1:=1;
for i:= 2 to 10 do
begin
    if (max < rad_num) then
    begin
    max:= rad_num ;
    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.

牡丹花下死做鬼 发表于 2013-9-20 20:51:47

你确定 你刚学?? 我刚刚看了三课 但你的代码 我......{:5_100:}
页: [1]
查看完整版本: 刚学的Dephi 大家帮忙看看我的代码哪里有问题!