![]() |
StringList "rotieren"?
Hallo DP!
Kennt jemand eine Möglichkeit, eine StringListe zu "drehen"? Also aus
Code:
würde
ABCDE
FGHIJ KLM
Code:
Die Strings haben hierbei eine feste Maximallänge
AFK
BGL CHM DI EJ Habe schon gesucht, nichts gefunden und auch keine wirkliche Idee für einen Algorithmus oder gar eine Implementation... Kann mir jemand helfen? Add: Habe jetzt ein halbwegs brauchbares Konstrukt gefunden, ich denke aber, dass hier etwas ordentliches herauskonnt... :thumb: |
Re: StringList "rotieren"?
Delphi-Quellcode:
Das wäre meine Idee zu dem Thema...
function Th4xX0r.ListRotation(Input: TStringList): TStringList;
var TempSTRs:array of string; I, J:integer; begin Result:=TStringList.Create; SetLength(TempSTRs, PWLen); for I:=0 to(Input.Count-1)do begin for J:=1 to(Length(Input.Strings[I]))do begin TempStrs[J-1]:=TempStrs[J-1]+Input.Strings[I][J]; end; end; for I:=0 to(High(TempStrs)) do Result.Add(TempStrs[I]); end; |
Re: StringList "rotieren"?
oder so:
Delphi-Quellcode:
Aufruf:
function RotateString(sl: TStrings): string;
const LINE_MAX_LENGTH = 10; var s: string; v, h: Integer; begin s := ''; for h := 1 to LINE_MAX_LENGTH do begin for v := 0 to sl.Count - 1 do s := s + Copy(sl[v], h, 1) s := s + #13#10; end; Result := s; end;
Delphi-Quellcode:
sl.Text := RotateString(sl);
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:49 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz