using System; class Program { static void Main(string[] args) { int[] redBalls = new int[33]; for (int i = 0; i < redBalls.Length; i++) { redBalls[i] = i + 1; } int[] blueBalls = new int[16]; for (int i = 0; i < blueBalls.Length; i++) { blueBalls[i] = i + 1; } int count = 0; for (int i = 0; i < redBalls.Length - 5; i++) { for (int j = i + 1; j < redBalls.Length - 4; j++) { for (int k = j + 1; k < redBalls.Length - 3; k++) { for (int m = k + 1; m < redBalls.Length - 2; m++) { for (int n = m + 1; n < redBalls.Length - 1; n++) { for (int p = n + 1; p < redBalls.Length; p++) { for (int q = 0; q < blueBalls.Length; q++) { Console.WriteLine($"{redBalls[i]}, {redBalls[j]}, {redBalls[k]}, {redBalls[m]}, {redBalls[n]}, {redBalls[p]}, {blueBalls[q]}"); count++; } } } } } } } Console.WriteLine($"共有 {count} 种双色球的组合。"); Console.ReadLine(); } }
以上代码将生成 177,210 种不同的双色球组合。