组数有7行,每行的数字是0-9不定的数字
要求每行每个数字都要组合一次,如
1
23
34
4
5
6
7把它分解成
1234567
1244567
1334567
1344567
请给写出代码

解决方案 »

  1.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      S1,S2,S3,S4,S5,S6,S7 : string;
      S : string;
      I1,I2,I3,I4,I5,I6,I7 : integer;
    begin
      S1 := IntToStr( 18 );
      S2 := IntToStr( 23 );
      S3 := IntToStr( 3 );
      S4 := IntToStr( 49 );
      S5 := IntToStr( 5 );
      S6 := IntToStr( 64 );
      S7 := IntToStr( 7 );  S := '';
      for I7 := 1 to Length(S7) do
        for I6 := 1 to Length(S6) do
          for I5 := 1 to Length(S5) do
            for I4 := 1 to Length(S4) do
              for I3 := 1 to Length(S3) do
                for I2 := 1 to Length(S2) do
                  for I1 := 1 to Length(S1) do
                    begin
                    S := S1[I1]+S2[I2]+S3[I3]+S4[I4]+S5[I5]+S6[I6]+S7[I7];
                    Memo1.Lines.Add(S);
                    end;
    end;
      

  2.   

    循环部分改成下面这样吧。 不过其实是一样的道理。  for I1 := 1 to Length(S1) do
        for I2 := 1 to Length(S2) do
          for I3 := 1 to Length(S3) do
            for I4 := 1 to Length(S4) do
              for I5 := 1 to Length(S5) do
                for I6 := 1 to Length(S6) do
                  for I7 := 1 to Length(S7) do
                    begin
                    S := S1[I1]+S2[I2]+S3[I3]+S4[I4]+S5[I5]+S6[I6]+S7[I7];
                    Memo1.Lines.Add(S);
                    end;
      

  3.   

    S1 := IntToStr( 18 );中18是什么意思?