unit min_max;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  n: Array Of Integer;
  Liczba: String;
  a, b, c: Integer;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
   SetLength(n, high(n) + 2);
   Liczba:= InputBox('Wprowadz liczbe','Podaj liczbe n','');
   n[High(n)]:= StrToInt(Liczba);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  FOR a:= Low(n) TO High(n) DO
     Begin
        FOR b:= Low(n) TO High(n) DO
           Begin
              IF n[b] < n[b - 1] THEN
                 Begin
                    c:= n[b];
                    n[b]:= n[b - 1];
                    n[b - 1]:= c;
                 End;
           End;
     End;
  Edit1.Text:= IntToStr (n[Low(n)]);
  Edit2.Text:= IntToStr (n[High(n)]);
end;
end.
