现在的位置: 首页 > 综合 > 正文

题目:输入三个整数x,y,z,请把这三个数由小到大输出

2013年09月12日 ⁄ 综合 ⁄ 共 802字 ⁄ 字号 评论关闭

 //题目:输入三个整数x,y,z,请把这三个数由小到大输出

using System;
using System.Collections.Generic;
using System.Text;

namespace Sf_4
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = 0;
            int y = 0;
            int z = 0;
            int nTemp = 0;

            Console.WriteLine("Please input three Nums :");

            x = int.Parse(Console.ReadLine());
            y = int.Parse(Console.ReadLine());
            z = int.Parse(Console.ReadLine());

            if (x > y)
            {
                nTemp = x;
                x = y;
                y = nTemp;
            }
            if (x > z)
            {
                nTemp = x;
                x = z;
                z = nTemp;
            }
            if (y > z)
            {
                nTemp = y;
                y = z;
                z = nTemp;
            }

            Console.WriteLine(x + " " + y + " " + z);
        }
    }
}

抱歉!评论已关闭.