Создать проект, в котором вводиться 5 чисел. Упорядочить их по возрастанию — Pascal(Паскаль)

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
const
  SIZE = 10;
var
  a: array [1 .. SIZE] of integer;
  min: integer;
  j: integer;
  buf: integer;

  i, k: integer;
begin

  for i := 1 to SIZE do
    a[i] := StrToInt(StringGrid1.Cells[i - 1, 0]);

  label2.caption := '';
  for i := 1 to SIZE - 1 do
  begin
    min := i;

    for j := i + 1 to SIZE do
      if a[j] < a[min] then
        min := j;

    buf := a[i];
    a[i] := a[min];
    a[min] := buf;

    { }

    for k := 1 to SIZE do
      label2.caption := label2.caption + ' ' + IntTostr(a[k]);
    label2.caption := label2.caption + #13;
  end;

  label2.caption := label2.caption + #13;
end;

end.

Leave a Comment

73 + = 77