我感觉for循环更简单一些- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace test6
- {
- class Program
- {
- public static int[] yue = new int[13];
- static void Main(string[] args)
- {
- //1、2、3、4这个四个数能组成多少个不同的三位数
- int[] nums = { 1, 2, 3, 4 };
- for (int i = 0; i < nums.Length; i++)
- {
- for (int j = 0; j < nums.Length; j++)
- {
- if (nums[i] == nums[j])
- {
- continue;
- }
- for (int m = 0; m < nums.Length; m++)
- {
- if (nums[i] == nums[m]||nums[j]==nums[m])
- {
- continue;
- }
- Console.WriteLine(nums[i] + "" + nums[j]+""+nums[m]);
- }
- }
- }
- Console.ReadKey();
- }
- }
- }
复制代码 |