C#怎么比较三个数的大小并按从大到小的顺序输出?要用if语句.
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/09/29 21:52:51
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);
}
}
}
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);
}
}
}
C#怎么比较三个数的大小并按从大到小的顺序输出?要用if语句.
java编程用IF语句做的.从键盘输入任意三个整数,用IF条件语句来比效三个数的大小,按大到小的顺序输出.
用汇编语言比较三个位数的大小,如果三个数相等 输出等号,如果三个不同 按从大到小的顺序输出,急用 !
C#编程求助:编程产生两个随机数a和b,并比较两个数的大小,按从小到大的顺序输出两个数.
怎么在VFP中设计比较三个数的大小的程序,并按由大到小输出
用C语言比较三个数的大小并输出最大的那个数
//输入三个整数,采用指针方法将三个数按从大到小的顺序输出
比较三个数的大小,输出比较结果
编写算法语句,输入两个数,安按由大到小的顺序输出 怎么写啊
利用C++编程,比较由键盘输入的三个数大小,并按从小到大依次输出,请问如何实现?
用C语言比较三个数的大小,并按照从大到小排序
用IF ELSE语句比较任意五个数的大小