编写一个程序,从键盘输入m,n的值。分别两次调用用户自定义函数来求解:m!/(m-n)!
2014-05-14
using System;
public class Class1
{
public static void Main()
{
Console.Write("输入m的值:");
int m = Convert.ToInt32(Console.ReadLine());
Console.Write("输入n的值:");
int n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("m!/(m-n)!={0}",jiecheng(m)/jiecheng(m-n));
}
static int jiecheng(int m)
{
int mm=1;
for (int i = 1; i <= m; i++)
{
mm *= i;
}
return mm;
}
}