unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
procedure getn(ss, ss1: string; count: Integer; var str: TStrings);
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
  s1,s2:string;
  str,str1:TStrings;
  i,j,m,n:Integer;
begin
  s1:=Trim(self.Edit1.Text);//这里就是你的字符串‘4,6,8,12,16,17,20,28,29,30,31’
  s2:=Trim(self.Edit2.Text);//这里输入8
  if (s1='') or (s2='') then
    Exit;
  str:=TStringList.Create;
  str.Clear;
  str1:=TStringList.Create;
  str1.Clear;
  self.getn(s1,'',StrToInt(s2),str);
  i:=str.Count;
  self.Memo1.Lines.Clear;
  for j:=0 to i-1 do
  begin
    s1:=str.Strings[j];
    self.Memo1.Lines.Add(s1);
  end;
end;procedure TForm1.getn(ss, ss1: string; count: Integer; var str: TStrings);
var
  i,j,m,n:Integer;
  s,s1,s2,s3:string;
  str1,str2:TStrings;
begin
  str1:=TStringList.Create;
  str1.Clear;
  str2:=TStringList.Create;
  str2.Clear;
  ExtractStrings([','],[],PChar(ss),str1);
  i:=str1.Count;
  if i=0 then
    Exit;
  for j:=1 to i do
  begin
    s1:=str1.Strings[j-1];
    if ss1='' then
      s3:=ss1+s1
    else
      s3:=ss1+'-'+s1;
    str2.Clear;
    ExtractStrings(['-'],[],PChar(s3),str2);
    if str2.Count=count then
    begin
      str.Add(s3);
      Continue;
    end;
    s2:='';
    for n:=j to i-1 do
      s2:=s2+str1.Strings[n]+',';
    Self.getn(s2,s3,count,str);
  end;
end;end.=====================================以上代码能否把Memo1内容横向显示??它当前显示模式如:
1234;
1235;
1236;
1237;
1238;
...希望实现效果如下:
1234;  1235;  1236;  1237; 1238;  ...