/*
* 小明有5本书,要借给ABC三位小朋友,若每人每次只能借1本书,则可以有多少种不同借法?
* 例:5本书编号:0,1,2,3,4
*/
1 int[] books = new int[5];
2 int count = 1;
3 for (int i = 0; i < books.Length; i++)
4 {
5 for (int m = 0; m < books.Length; m++)
6 {
7 if (m == i)
8 continue;
9
10 for (int n = 0; n < books.Length; n++)
11 {
12 if (n == m || n == i)
13 continue;
14
15 Console.WriteLine(count + ":" + i + " " + m + " " + n);
16 count++;
17 }
18 }
19 }
2 int count = 1;
3 for (int i = 0; i < books.Length; i++)
4 {
5 for (int m = 0; m < books.Length; m++)
6 {
7 if (m == i)
8 continue;
9
10 for (int n = 0; n < books.Length; n++)
11 {
12 if (n == m || n == i)
13 continue;
14
15 Console.WriteLine(count + ":" + i + " " + m + " " + n);
16 count++;
17 }
18 }
19 }