根据字符串中的第一个数字递增

Increment based on the first numbers in a string

我真的希望你明白我在做什么^^

所以我有一个函数应该增加一个数字。我给这个函数一个字符串,它是一个基于几个数字的字符串。例如我的函数(“64”);

我的目的是像这样增加这个字符串:

641
642
643
...
6410
6411
6412
...
6421
6422
...
6431
6432
...
64110
64111
....
64220
...

641
6410
64100
6411
64111
64112
64113
..
64119
6412
64120
64121
...
and so on until 64999.

到目前为止,这是我的逻辑:

procedure tForm1.IterateEveryPossibilities(c: String);
var
   cLength: Integer;
   i,j: Integer
   sI: String; 
begin
   cLength : Length(x); //This is the length of the string
   for i : cLength+1 to 5 do // maximum length of the number is 5. there's no number over 99999
   begin
      for j := 0 to 9 do // adding 0 , 1 , 2 , ... 9 to the number
      begin
        si := c + intToStr(j);
      end;
     C := sI;
   end;
  end;

我试图了解我必须添加多少数字,最后只添加 1,2,...9 a。但它不会尝试像 11 12 13 这样的数字,它只是 641 642.... 649,然后是 6491 6492 6493,并且不要尝试 6410 6411。

你能帮帮我吗?我找不到这个逻辑:/

谢谢

如果我理解你的问题,请纠正这应该对你有用:

function IterateEveryPossibilities(c: string): string;
const
  Min = 1;
  Max = 999;
var
  Buffer: TStringList;
  i: Integer;
begin
  Buffer := TStringList.Create;
  try
    Buffer.LineBreak := ' ';

    for i := Min to Max do
      Buffer.Add(c + IntToStr(i));

    Result := Buffer.Text;
  finally
    Buffer.Free;
  end;
end;