...implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);var i,j,iRow,iCount,iC,k,m,n:Integer; s,s1:string; A:array of array of char; ALen:array of Integer;begin Memo2.Clear; { Memo1.Clear; Memo1.Lines.Add('ABC'); Memo1.Lines.Add('DE'); Memo1.Lines.Add('GH'); } iRow:=Memo1.Lines.Count; if iRow=1 then begin Memo2.Lines.Add(Memo1.Lines[0]); exit; end; SetLength(ALen,iRow); iCount:=1; for i:=0 to iRow-1 do begin ALen:=length(Memo1.Lines); iCount:=iCount*ALen; end; SetLength(A,iCount,iRow); for i:=0 to iRow-1 do begin s:=Memo1.Lines; iC:=1; for k:=i+1 to iRow-1 do iC:=iC*ALen[k]; n:=iCount div (iC*ALen); s1:=''; for j:=1 to n do for k:=1 to length(s) do for m:=0 to iC-1 do s1:=s1+s[k]; for k:=1 to length(s1) do A[k-1]:=s1[k]; end; for i:=0 to iCount-1 do begin s:=''; for j:=0 to iRow-1 do s:=s+A[j]+' '; Memo2.Lines.Add(s); end; SetLength(ALen,0); for i:=0 to iRow-1 do SetLength(A,i,0); SetLength(A,0);end;