{
Console.WriteLine("你好!");
}
//函数类型
//第一种:无参无返
public void Leijia()
{
Console.Write("请输入一个正整数:");
int a = int.Parse(Console.ReadLine());
int sum = 0;
for (int i = 1; i <= a; i++)
{
sum += i;
}
Console.WriteLine(sum);
Console.ReadLine();
}
//第二种,有参无返
public void Leijia(int a)
{
int sum = 0;
for (int i = 1; i <= a; i++)
{
sum += i;
}
Console.WriteLine(sum);
Console.ReadLine();
}
//第三种,有参有返
public int Leijia1(int b)
{
int sum = 0;
for (int i = 1; i <= b; i++)
{
sum += i;
}
return sum;
}
//第四种,有返无参
public int Leijia2()
{
Console.Write("请输入一个正整数:");
int a = int.Parse(Console.ReadLine());
int sum = 0;
for (int i = 1; i <= a; i++)
{
sum += i;
}
return sum;
}
/// <summary>
/// 输入两个数比较大小,返回较大的
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public double Max(double a ,double b)
{
if (a > b)
{
return a;
}
else
{
return b;
}
}
static void Main(string[] args)
{
//写一个函数,能够比较大小
//三个数比较大小
double a = 3;
double b = 5, c = 2;
Program hanshu = new Program();
double max = hanshu.Max( hanshu.Max(a, b),c);
Console.WriteLine(max);
Console.ReadLine();
//Console.Write("请输入一个正整数:");
//int a = int.Parse(Console.ReadLine());
//Program hanshu = new Program();
//int sum = hanshu.Leijia2();
//Console.WriteLine(sum);
//Console.ReadLine();
//int sum= hanshu.Leijia1(a);
//Console.WriteLine(sum);
//Console.ReadLine();
//hanshu.Leijia(a);
// hanshu.Leijia();
////调用函数 初始化
//Program hanshu = new Program();
//hanshu.dayin();
//Console.ReadLine();
//Random ran = new Random();
//int aa= ran.Next(101);