马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm1 = class(TForm)
Edit1: TEdit;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
function paixu(var n:Integer):String;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
var
num:Array of Integer;
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
var
Str:String;
i,j:Integer;
temp:String;
begin
Str:=Trim( Edit1.Text );
SetLength(num,Length(Str));
i:=1;
j:=1;
While ( i<=Length(Str) ) do
begin
While ((Str[i]<>#32)And(Str[i]<>#0)) do
begin
temp:=temp+Str[i];
i:=i+1;
end;
num[j]:=StrToInt(temp);
j:=j+1;
i:=i+1;
temp:='';
Edit1.Text:=paixu(i-1); //系统提示此处有问题 Types of actual and formal var parameters must be idential
end;
end;
function TForm1.paixu(var n:Integer):String;
var
temp:Integer;
m,k,j:Integer;
begin
For m:=1 to n-1 do
begin
k:=n-m;
For j:=1 to k do
begin
If (num[j]>num[j+1]) then
begin
temp:=num[j];
num[j]:=num[j+1];
num[j+1]:=temp;
end;
end;
end;
Edit1.Text:='';
For j:=1 to n do
Result:=Edit1.Text+' '+IntToStr(num[j]);
end;
end.
|