C#编程求最大值

来源:百度知道 编辑:UC知道 时间:2024/05/21 05:11:28
在C#编程环境中! 利用条件语句if及其他IF语句求3个数的最大值!`

int a=1,b=2,c=3;
if(a>b && a>c)Console.writeline(a);
if(b>a && b>c)Console.writeline(b);
if(c>a && c>b)Console.writeline(c);

o(╯□╰)o

int max (int a, int b, int c)
{
if(a>b)
{
if(a>c) return c;
else return c;
}
else
{
if(b>c) return b;
else return c;
}
}

int max(int a,int b,int c)
{
if(a<b) a=b;
if(a<c) a=c;
return a;
}