使用数字

时间:2018-02-20 05:02:25

标签: c#

我有这样的代码:

static string[] numStr = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
    static string[] alphaStr = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Z" };

private static void Quiz_2()
    {
        for (int w = 0; w < alphaStr.Length; w++)
        {
            for (int v = 0; v < alphaStr.Length; v++)
            {
                for (int u = 0; u < alphaStr.Length; u++)
                {
                    for (int t = 0; t < alphaStr.Length; t++)
                    {
                        for (int s = 0; s < alphaStr.Length; s++)
                        {
                            for (int r = 0; r < alphaStr.Length; r++)
                            {
                                for (int o = 0; o < alphaStr.Length; o++)
                                {
                                    for (int n = 0; n < alphaStr.Length; n++)
                                    {
                                        for (int m = 0; m < alphaStr.Length; m++)
                                        {
                                            for (int i = 0; i < alphaStr.Length; i++)
                                            {
                                                for (int j = 0; j < numStr.Length; j++)
                                                {
                                                    for (int k = 0; k < numStr.Length; k++)
                                                    {
                                                        for (int l = 0; l < numStr.Length; l++)
                                                        {
                                                            Console.Write(alphaStr[w] + alphaStr[v] + alphaStr[u] + alphaStr[t] + alphaStr[s] + alphaStr[r] + alphaStr[o] + alphaStr[n] + alphaStr[m] + alphaStr[i] + numStr[j] + numStr[k] + numStr[l] + " ");
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

如果我运行我的程序,结果显示如下: AAAAAAAAAA000 .. AAAAAAAAAA999 AAAAAAAAAB000 .. AAAAAAAAAB999 AAAAAAAAAC000 AAAAAAAAAC001

我的预期结果:

AAAAAAAAAA000 .. AAAAAAAAAA999 AAAAAAAAAB000 .. AAAAAAAAAB999 AAAAAAAABB000 AAAAAAAABB001

任何人都可以帮助我吗?

2 个答案:

答案 0 :(得分:1)

使用递归:

mysql.connector.errors.DatabaseError: 1787 (HY000): Statement violates GTID consistency: CREATE TEMPORARY TABLE and DROP TEMPORARY TABLE can only be executed outside transactional context.  These statements are also not allowed in a function or trigger because functions and triggers are also considered to be multi-statement transactions.

答案 1 :(得分:-1)

你最好编写一个for循环并添加一些逻辑。

这就是我的意思:

class Program
{
   static void Main(string[] args)
   {
       string s = "AAAAAAAAAAAA";
       for(int i=0; i<s.Length; i++)
       {             
         for(int j=0; j<=999; j++)
         {
           (s + j.ToString("D3")).Dump();
         }

         //And now do some logic to increment the string
         //I'm not 100% sure what you want, maybe something like this?
         //First char = 'A'. Find the last char in the string <> 'A' and change it to 'A'+1
         //If none are found, all chars are the same, last char++
       }
    }
}