代码如下,希望对你有帮助:
class Program
{
static void Main(string[] args)
{
float x;
float y;
float z;
Console.WriteLine("请输入三个数字:");
x = float.Parse(Console.ReadLine());
y = float.Parse(Console.ReadLine());
z = float.Parse(Console.ReadLine());
if (x > y)
{
if (y > z)
{
Console.WriteLine("升序排列后的结果为:");
Console.WriteLine(z);
Console.WriteLine(y);
Console.WriteLine(x);
Console.ReadLine();
}
else
{
if(x>z)
{
Console.WriteLine("升序排列后的结果为:");
Console.WriteLine(y);
Console.WriteLine(z);
Console.WriteLine(x);
Console.ReadLine();
}
else
{
Console.WriteLine("升序排列后的结果为:");
Console.WriteLine(y);
Console.WriteLine(x);
Console.WriteLine(z);
Console.ReadLine();
}
}
}
else
{
if (y
Console.WriteLine("升序排列后的结果为:");
Console.WriteLine(x);
Console.WriteLine(y);
Console.WriteLine(z);
Console.ReadLine();
}
else
{
if (x>z)
{
Console.WriteLine("升序排列后的结果为:");
Console.WriteLine(z);
Console.WriteLine(x);
Console.WriteLine(y);
Console.ReadLine();
}
else
{
Console.WriteLine("升序排列后的结果为:");
Console.WriteLine(x);
Console.WriteLine(z);
Console.WriteLine(y);
Console.ReadLine();
}
}
}
}
}
static void Main(string[] args)
{
float x, y, z;
Console.Write("输入第一个数:");
x = float.Parse(Console.ReadLine());
Console.Write("输入第二个数:");
y = float.Parse(Console.ReadLine());
Console.Write("输入第三个数:");
z = float.Parse(Console.ReadLine());
MinToMax(x, y, z);
}
static void MinToMax(float a, float b, float c)
{
if (a > b && a > c)
{
if (b > c)
{
Console.WriteLine("{0}\t{1}\t{2}", c, b, a);
}
else
{
Console.WriteLine("{0}\t{1}\t{2}", b, c, a);
}
}
if (b > a && b > c)
{
if (a > c)
{
Console.WriteLine("{0}\t{1}\t{2}", c, a, b);
}
else
{
Console.WriteLine("{0}\t{1}\t{2}", a, c, b);
}
}
if (c > b && c > a)
{
if (b > a)
{
Console.WriteLine("{0}\t{1}\t{2}", a, b, c);
}
else
{
Console.WriteLine("{0}\t{1}\t{2}", b, a, c);
}
}
}