没说这4个字母是怎么选出来的,但组合却可以
function GetList(const Str: string; const iCount: Integer; Strs: TStrings): Integer;
var
S: string;
function GetAList: string;
function GetString: string;
begin
Result := S;
Delete(Result, 2, 1);
Strs.BeginUpdate;
try
while Length(S) > iCount - 1 do
begin
Strs.Add(Copy(S, 1, iCount));
Delete(S, iCount, 1);
end;
finally
Strs.EndUpdate;
end;
end;
begin
Result := S;
Delete(Result, 1, 1);
repeat
S := GetString;
until Length(S) < iCount;
end;
begin
Strs.Clear;
Result := 0;
if Length(Str) < iCount then Exit;
S := Str;`
if iCount = 1 then
repeat
Strs.Add(S[1]);
Delete(S, 1, 1);
until Length(S) < iCount
else
repeat
S := GetAList;
until Length(S) < iCount;
Result := Strs.Count;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Caption := IntToStr(GetList('ADHM', 3, Memo1.Lines));
end;