All pastes #547723 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-06-07 13:57 UTC
rendered paste body
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    ListBox_SortedF: TListBox;
    ListBox_SortedT: TListBox;
    Button_Sort: TButton;
    MainMenu1: TMainMenu;
    Menu_File: TMenuItem;
    Menu_Open: TMenuItem;
    OpenDialog: TOpenDialog;
    procedure Menu_OpenClick(Sender: TObject);
    procedure Button_SortClick(Sender: TObject);
  private
  public
  end;

var
  Form1: TForm1;
  pole:array[1..1000] of integer;
  
implementation

{$R *.dfm}

procedure TForm1.Menu_OpenClick(Sender: TObject);
var
  souborki:textfile;
  pole:array[1..1000] of integer;
  i,j:integer;
begin
OpenDialog.execute;

assignfile(souborki, opendialog.FileName);
reset(souborki);
j:=1;
while not eof(souborki) do
    begin
      readln(souborki, i);
      pole[j]:=i;
      listbox_SortedF.Items.add(inttostr(I));
      i:=i+1;
    end;
end;

procedure TForm1.Button_SortClick(Sender: TObject);
var
pocet,tmp,a:integer;
begin
pocet:=listbox_sortedF.items.count;
for a := 1 to pocet-1 do
  begin
    if pole[a] > pole[a+1] then
      begin
        tmp:=pole[a+1];
        pole[a]:=pole[a+1];
        pole[a+1]:=tmp;
      end;
  end;

end;

end.