首页  编辑  

阶梯

Tags: /超级猛料/Friends.网友专栏/zswang/函数大全/   Date Created:

function ZsLadder(mText: string; mLength: Integer = 0): string; { 阶梯 }

var

 I, L: Integer;

 S, T: string;

begin

 Result := '';

 L := Length(mText);

 if L < 1 then Exit;

 if mLength <= 0 then mLength := L;

 S := '';

 for I := 1 to mLength do S := S + mText[1]; //00000

 T := '';

 for I := 1 to mLength do T := T + mText[L]; //44444

 while S <> T do begin

   Result := Result + S + #13#10;

   for I := mLength downto 1 do

     if S[I] = mText[L] then

       S[I] := mText[1]

     else begin

       S[I] := mText[Pos(S[I], mText) + 1];

       Break;

     end;

 end;

 Result := Result + S + #13#10;

end; { ZsLadder }

procedure TForm1.Button1Click(Sender: TObject);

begin

 Memo1.Text := ZsLadder(Edit1.Text, 3);

end;

procedure TForm1.FormCreate(Sender: TObject);

begin

 Edit1.Text := '012';

end;