感谢《[Delphi.7应用教程].童爱红.文字版.pdf》提供的题目、解题方法及文字源程序!本文作者据此转换为Delphi源程序(为方便爱好者学习,程序界面略有修改,源程序包请见附件):

unit SL421;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, jpeg, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    GroupBox1: TGroupBox;
    Image1: TImage;
    GroupBox2: TGroupBox;
    Memo1: TMemo;
    GroupBox3: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    Button2: TButton;
    GroupBox4: TGroupBox;
    Memo2: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Only_Num(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
var
  num:Array[1..10] of Integer; //定义一个单元级数组变量,存储输入的10个数

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject); //【输入】按钮代码
var
  m:integer;
begin
  edit1.text:='';
  edit2.text:='';
  for m:=1 to 10 do
    begin
      num[m]:=StrToInt(InputBox('请输入10个整数','输入第'+IntToStr(m)+'个整数','0'));
      edit1.text:=edit1.text+IntToStr(num[m])+' ,'
    end;
  edit1.text:=copy(edit1.text,1,Length(edit1.text)-1);
   //文件框的文本取从第1个字符起,到除了最后1个字符之外的所有字符
end;

procedure TForm1.Button2Click(Sender: TObject);
Var
  i,j,k,n:integer;
begin
  for i:=1 to 9 do
    begin
      k:=10-i ;  //第i轮比较10-i次
      for j:=1 to k do
        begin
          if num[j]>num[j+1] then   //如果num[j]>num[j+1]就交换两数
            begin
              n:=num[j];
              num[j]:=num[j+1];
              num[j+1]:=n;
            end;

        end;
    end;
   for i:=1 to 10 do
     edit2.Text:=edit2.text+IntToStr(num[i])+' ,';
   edit2.Text:=copy(edit2.text,1,length(edit2.text)-1);
end;

procedure TForm1.Only_Num(Sender: TObject; var Key: Char);
begin
  if not (key in['0'..'9',#8]) then key:=#13;    //文本框只能输入数字
end;

end.