用C# 求三个整数的最大值 编写一个程序,使用条件运算符求用户输入的三个整数中的最大值。

如题所述

int a=Int32.Parse(FirstOperand.Text);
int b=Int32.Parse(SecondOperand.Text);
int c=Int32.Parse(TirchdOperand.Text);
//以下可在Button控件下输入(双击Button)
if(a<=b)
{if(b<=c)Console.Write("最大值为"+c);
else Console.Write("最大值为"+b);
}
else
{ if(a<=c)Console.Write("最大值为"+c);
else Console.Write("最大值为"+a);
}
FirstOperand;SecondOperand;TirchdOperand为自建的TextBox控件
我没运行试试吧……
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-03-12
赚钱鲁过
第2个回答  2012-03-13
int max(int a,int b,int c){
(a>b)?b=a:b=b;
(b>c)?return b:return c;
}

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网