можно ли ее сделать так? если нет,то подскаите......запутался уже.
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
type
TPWord1=^TL;
TL=record
st:string[20];
next:TPWord1; end;
var
head1:TPWord1;
count,i,j:integer; curr:TPWord1; st:string;
mass1:array[1..10]of byte;
n,a:byte;
procedure TForm1.Button1Click(Sender: TObject);
begin
for i:=Memo1.Lines.Capacity downto 0 do
begin
inc(count);
new(curr);
curr^.st :=Memo1.Lines.Strings[i] ;
curr^.next := head1;
head1 := curr;
end;
Button1.Enabled:=false;
a:=0;
n:=0; curr:=head1;
while n < count-1 do begin
inc(n);
mass1[n]:=strtoint(curr^.st);
curr := curr^.next;
end;
for i:=1 to count-1 do
for j:=1 to count-2 do
if mass1[j]>mass1[j+1]
then
begin
a:=mass1[j];
mass1[j]:=mass1[j+1];
mass1[j+1]:=a;
end;
n:=0;
for i:=1 to count-1 do begin
new(curr);
curr^.st :=inttostr(mass1[i]);
curr^.next := head1;
head1 := curr;
end;
while n < count-1 do
begin
inc(n);
st:=st+#13+curr^.st;
curr := curr^.next;
end;
if st='' then ShowMessage('Ñïèñîê ïóñò')
else ShowMessage('Ðåçóëüòàò:'+st);
end;
end.