⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 Componente Delphi para Array
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Grids;

type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    Edit1: TEdit;
    Button1: TButton;
    Button2: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  num: array[1..20] of integer;
  aux, fim, ini, pri, seg: integer;
  i, i2, tot: integer;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
   i := i+1;
   num[i] := StrToInt(Edit1.Text);
   StringGrid1.Cells[0,i-1] := inttostr(num[i]);
   Edit1.Clear;
   Edit1.Setfocus;
   tot := i;
   Label1.Caption := 'Total: ' + IntToStr(tot);

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
   for i:= 1 to tot-1 do
         for i2 := i+1 to tot do
               if num[i] > num[i2] then begin
                     aux := num[i];
                     num[i] := num[i2];
                     num[i2] := aux;
               end;
//coloca no grid
   for i := 1 to tot do
       StringGrid1.Cells[0,(i-1)] := IntToStr(num[i]);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -