有一组8位数的数字,其中的数字在3-8之间,就是说这组数字只包括(3、4、5、6、7、8);怎么循环输出它产生的所有数组。 

解决方案 »

  1.   

    引用:using System.Text.RegularExpressions;
    for (int i = 33333333; i <= 88888888; i++)
            {
                string si=i.ToString();
                string r = Regex.Replace(si, "[0-2,9]", "");
                if (si == r)
                {
                    Response.Write(si+"<br/>");
                }
            }
      

  2.   

      string[] ss = {"0","1","2","9" };
               System.Collections.ArrayList a = new System.Collections.ArrayList();
               int index = 0;
               for (int i = 33345678; i <= 88876543; i++) //取最大数与最小数
               {
                   bool f = false;
                   foreach (string s in ss)
                   {
                       if (i.ToString().IndexOf(s) != -1) //存在0,1,2,9
                       {
                           f = true; break;
                       }
                   }
                   if (f) continue;
                   a.Add(i);  //存储该值
                   
               }
      

  3.   

    递归
    main()
    {
      cal( 0 );
    }void cal( int n )
    {
      if( n > 10000000 )
      {
        printf(n);
        return;
      }
      
      for( int i = 3; i <= 8; i++ )
        cal(n*10 + i);
    }没有测试,应该没问题吧,好运。
      

  4.   

    public static string ConvetToBaseSix(int num)
    {
        string result = "";    while (num >= 6)
        {
            result = ((num % 6) + 3) + result;
            num = num / 6;
        }
        result = (num + 3) + result;    for (int i = result.Length; i < 8; i++)
        {
            result = "3" + result;
        }    return result;
    }
    num输入的十进制下对应的数字0 ==> 33333333
    1 ==> 33333334
      

  5.   

    原理是:  0 ==> 00000000 ==> 33333333
      1 ==> 00000001 ==> 33333334
    ...
      4 ==> 00000004 ==> 33333337
      5 ==> 00000005 ==> 33333338
      6 ==> 00000010 ==> 33333343
    ...
      9 ==> 00000013 ==> 33333346
    10 ==> 00000014 ==> 33333347