C#怎么比较三个数的大小并按从大到小的顺序输出?要用if语句.

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/17 21:28:03
C#怎么比较三个数的大小并按从大到小的顺序输出?要用if语句.
xVQ@+K‘z۵9/ >,I(*p'½ j_SIMgBL~ͤBC+]ywmr舯>D vgoǧGYuuOBo5 b۴{-wbd:%63ޤ$TbQBxA:PT$C , ǿ"0cBwLf" l}Um̸b&5+)lAo2wdB' ]gLn'vohu FEOM[3naeԻW4Rr)(cvQySQZ TYjX)iE9 x$KP>qOι,!II7EQ"*X+lhrJXFېx`\ aB )1NXK\5_IkP:ɸC&U&ߋ-!BKI5mH,$&G:O$E k +Uw+{"%3鼆S#+ލ٨ae6j+׹:ۮsu57%'E|ۉZ <0

C#怎么比较三个数的大小并按从大到小的顺序输出?要用if语句.
C#怎么比较三个数的大小并按从大到小的顺序输出?要用if语句.

C#怎么比较三个数的大小并按从大到小的顺序输出?要用if语句.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入三个数:");
double a = Convert.ToDouble (Console .ReadLine ());
double b = Convert.ToDouble(Console.ReadLine());
double c = Convert.ToDouble(Console.ReadLine());
double ? max=null ;
double ? middle =null ;
double ? min=null ;
if (a >= b && b >= c)
{
max = a;
middle = b;
min = c;
}
else
if(a>=c&&c>=b)
{
max = a;
middle = c;
min = b;



}
else
if (b >= a && a >= c)
{
max = b;
middle = a;
min = c;

}
else
if (b >= c && c >= a)
{
max = b;
middle = c;
min = a;

}
else
if (c>= a && a >= b)
{
max = c;
middle = a;
min = b;

}
else
if (c >= b && b >= a)
{
max = c;
middle = b;
min = a;

}
Console.WriteLine ("排序后的序列为(从大到小):{0}{1}{2}{3}{4}",max ,",",middle,"," ,min);
}
}
}