帮我解决这个问题,我这有很多源代码送上
从0到9的10个数中随意取出5个数,这5个数由sle_1.text,sle_2.text,...sle_5.text来定,是由用户输入的。由这5个数组成5位数,5位数中5个数都要包含。共有多少种?要代码啊!!
  举个例子:选的5位数是2,4,6,8,0 那么这个5位数可能是:
     24680,24608,42680,等等,就是2,4,6,8,0一个都不能少
代码啊!!
另外如果有sle_1.text有4,6,7个,情况和上面相同,那么代码又该如何写呢?
写出来后一定要可以打印,可以看到有那些数
那位帮我,我定报答!!

解决方案 »

  1.   

    var i,j,k,l,m:integer;
        r:array[1..5] of 0..9;
    begin
      try
        r[1]:=strtoint(sle_1.text);
        r[2]:=strtoint(sle_2.text);
        r[3]:=strtoint(sle_3.text);
        r[4]:=strtoint(sle_4.text);
        r[5]:=strtoint(sle_5.text);
      except
         raise exception.Create('数据输入错误');
      end;
      if((not (r[1] in [0..9]))
         or (not (r[2] in [0..9]))
         or (not (r[3] in [0..9]))
         or (not (r[4] in [0..9]))
         or (not (r[5] in [0..9]))
         or (r[1]=r[2])
         or (r[1]=r[3])
         or (r[1]=r[4])
         or (r[1]=r[5])
         or (r[2]=r[3])
         or (r[2]=r[4])
         or (r[2]=r[5])
         or (r[3]=r[4])
         or (r[3]=r[5])
         or (r[4]=r[5]))
        then  raise exception.Create('数据输入错误');
        for i:=1 to 5 do
          for j:=1 to 5 do
            for k:=1 to 5 do
              for l:=1 to 5 do
                for m:=1 to 5 do begin
                  if ((r[i]<>0) and
                     (i<>j) and
                     (i<>k) and
                     (i<>l) and
                     (i<>m) and
                     (j<>k) and
                     (j<>l) and
                     (j<>m) and
                     (k<>l) and
                     (k<>m) and
                     (l<>m))then
                     listbox1.Items.Add(format('%d%d%d%d%d',[r[i],r[j],r[k],r[l],r[m]]));
                end;
      

  2.   

    sorry,cuo 了,多了一个,楼上的正确!