Code
using System;
using System.Collections.Generic;
using System.Text;
namespace ExFactorial
{
class Factorial
{
public double factorial(int num)
{
switch (num)
{
case 1:
return 1;
default :
return num * factorial(num - 1);
}
}
static void Main(string[] args)
{
Console.WriteLine("输入一个整数:");
int num=Convert.ToInt32 (Console.ReadLine());
Factorial f = new Factorial();
Console.WriteLine("{0}!的值为{1}", num, f.factorial(num));
Console.ReadLine();
}
}
}
posted @
2009-01-12 18:58
jianlinglo
阅读(
142)
评论()
编辑
收藏
举报