您的位置:首页 > 其它

一个借书方案(运用排列)

2007-10-29 16:46 288 查看
   如果A有N本书,我们要将这N本书分给三个人,有多少中分法。

程序实现如下:

1 using System;

2 using System.Collections.Generic;

3 using System.Text;

4

5 namespace Test

6 {

7 class Program

8 {

9 static void Main(string[] args)

{

int a, b, c, d, count = 0;

Console.Write("How many books:");

d = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("There are different methods for XM to distribute books to 3 Readers:");

for (a = 1; a <= d; a++)

for (b = 1; b <= d; b++)

for (c = 1; a != b && c <= d; c++)

if (c != a && c != b)

Console.WriteLine("{0}: {1},{2},{3}", ++count, a, b, c);

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: