Показать сообщение отдельно
  #14  
Старый 02.06.2010, 11:43
Add_Mod Add_Mod вне форума
Прохожий
 
Регистрация: 08.05.2010
Сообщения: 18
Репутация: 10
По умолчанию

Что-то не робит по вашей сортировке, выводит в строку содержимое файла и всё, может всё таки где то я кривой)):
unit Unit1;

interface

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

type
TForm1 = class(TForm)
Label2: TLabel;
GroupBox1: TGroupBox;
Label1: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
GroupBox2: TGroupBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Edit1: TEdit;
Label8: TLabel;
Button4: TButton;
MainMenu1: TMainMenu;
Memo1: TMemo;
Memo2: TMemo;
N1: TMenuItem;
Label9: TLabel;
N2: TMenuItem;
Label10: TLabel;
OpenDialog1: TOpenDialog;
Label11: TLabel;
Label12: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure N1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const
n=20;
var
Form1: TForm1;

implementation

{$R *.dfm}

function NumberSort(List: TStringList; Index1, Index2: Integer): Integer;
begin
Result := 0;
if StrToInt(List.Strings[Index1]) > StrToInt(List.Strings[Index2]) then Result := 1;
if StrToInt(List.Strings[Index1]) < StrToInt(List.Strings[Index2]) then Result := -1;
end;

procedure TForm1.N1Click(Sender: TObject);
var
b:array[1..10]of integer;
t:textfile;
SL: TStringList;
sum:Integer;
begin
SL := TStringList.Create();
SL.LoadFromFile('ms.txt');
SL.CustomSort(@NumberSort);
Memo1.Lines := SL;
SL.Free;
end;

end.
Ответить с цитированием