2个回答
展开全部
不用memo控件,采用edit控件程序:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
st,s,ss:string;
a:array[1..100] of integer;
i,j,k:integer;
p,q,t:integer;
begin
st:=edit1.Text;
i:=0;
while pos(',',st)>0 do begin
s:=copy(st,1,pos(',',st)-1);
val(s,j,k);
inc(i);
a[i]:=j;
delete(st,1,pos(',',st));
end;
val(st,j,k);
inc(i);
a[i]:=j;
for p:=1 to i-1 do for q:=p+1 to i do
if a[p]>a[q] then begin t:=a[p]; a[p]:=a[q]; a[q]:=t; end;
str(a[1]:0,ss);
for p:=2 to i do begin str(a[p]:0,s); ss:=ss+','+s; end;
edit1.Text:=ss;
end;
end.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询