4个数比大小

while (true)
{
int a, b, c, d;
Console.WriteLine("请输入第1个数:");
a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入第2个数:");
b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入第3个数:");
c = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入第4个数:");
d= Convert.ToInt32(Console.ReadLine());

if(a>=b&&a>=c&&a>=d)
{
Console.WriteLine(a+"最大");
}
else if (b >= a && b >= c&&b>=d)
{
Console.WriteLine(b+"最大");
}
else if (c >= a && c >= b&&c>=d)
{
Console.WriteLine(c+"最大");
}
else if (d >= a && d >= b && d >= c)
{
Console.WriteLine(d + "最大");
}
else
{
Console.WriteLine("1");

posted @ 2015-03-30 14:55  耿鹏飞  阅读(286)  评论(0编辑  收藏  举报