about me
Google_search
hot
latest
photos
links
用C#写的一个阶乘
来源:来自网络 作者:不详 日期:2007-12-29 热度:程序代码
using System;
namespace ConsoleApplication1
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
int n;
public int function(int i)
{
if( i <= 1 )
{
return 1;
}
else
{
int s=i*function(i-1);
return s;
}
}
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
Console.WriteLine("输入数字N:");
Class1 c1=new Class1();
try
{
c1.n = Convert.ToInt32(Console.ReadLine());
}
catch(FormatException e)
{
Console.WriteLine(e.Message);
}
int nResult=c1.function(c1.n);
Console.WriteLine(nResult);
}
}
}
namespace ConsoleApplication1
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
int n;
public int function(int i)
{
if( i <= 1 )
{
return 1;
}
else
{
int s=i*function(i-1);
return s;
}
}
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
Console.WriteLine("输入数字N:");
Class1 c1=new Class1();
try
{
c1.n = Convert.ToInt32(Console.ReadLine());
}
catch(FormatException e)
{
Console.WriteLine(e.Message);
}
int nResult=c1.function(c1.n);
Console.WriteLine(nResult);
}
}
}
↑ 返回顶部
Tags: C#
广告位招租,广告代号:gg468
↑ 返回顶部
search
advertise




![还你真实的开幕式!震撼美图[转]【连载】](/up_files/image/Article/2008/08/12/57015031.jpg)



