if else

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace if_else
{
    class Program
    {
        static void Main(string[] args)
        {
            //语句的分类
            //顺序语句
            //分支语句(选择语句)
            //循环语句

            //分支语句
            //if (表达式) //表达式返回值是True或False
            //{
            //}
            //int a = 113;
            //if (a <= 100)
            //{
            //    Console.WriteLine("您输入的数是小于等于100的。");
            //}
            //if (a > 0)
            //{
            //    Console.WriteLine("您输入的数是大于0的");
            //}
            //Console.ReadLine();


            //格式2     二选一
            //if (表达式)
            //{
            //}
            //else如果if不执行,else一定执行(其他的,另外的)
            //{
            //}
            //Console.Write("请随意输入一个整数:");
            //int a = int.Parse(Console.ReadLine());
            //if (a >= 0 && a <= 100)//0<=a<=100
            //{
            //    Console.WriteLine("您输入的数是0~100之间的。");
            //}
            //else//表示的是a<0 || a>100的情况
            //{
            //    Console.WriteLine("您输入的数不是0~100之间的。");
            //}
            //Console.ReadLine();
            //输入年龄,大于等于18显示成年,否则显示未成年。
            //Console.Write("请输入你的年龄:");
            //int age = int.Parse(Console.ReadLine());
            //if (age >= 0 && age <= 135)//首先规定大范围(0~135之间)
            //{
            //    if (age >= 18)
            //    {
            //        Console.WriteLine("成年");
            //    }
            //    else
            //    {
            //        Console.WriteLine("未成年");
            //    }
            //}
            //else//不符合人的年龄范围
            //{
            //    Console.WriteLine("您输入的不是人的年龄范围!");
            //}






            //Console.ReadLine();


            //格式3    多选一
            //            if(表达式)
            //{
            //}
            //else if()
            //{
            //}
            //else if()
            //{
            //}
            //...
            //else
            //{
            //}


            //if(表达式)
            //{
            //    if(){}
            //      else{}
            //}
            //else
            //{
            //    if(){}
            //}
            //if嵌套


            //输入一个100以内的整数,判断是小于10的还是两位数还是100
            //Console.Write("请输入一个100以内的数:");
            //int a = int.Parse(Console.ReadLine());
            //if (a <= 100)
            //{
            //    if (a < 10)
            //    {
            //        Console.WriteLine("您输入的是一个小于10的数。");
            //    }
            //    else if (a >= 10 && a <= 99)
            //    {
            //        Console.WriteLine("您输入的是一个两位数。");
            //    }
            //    else//100
            //    {
            //        Console.WriteLine("您输入的数是100。");
            //    }
            //}
            //else
            //{
            //    Console.WriteLine("您的输入有误!");
            //}
            //Console.ReadLine();



            //输入分数判断是否及格,>=80输出学的不错,60~80刚刚及格,继续加油,50~59输出就差一点
            //<50输出使劲努力,不要偷懒
            //Console.Write("请输入您的分数:");
            //double score = double.Parse(Console.ReadLine());
            //if (score >= 0 && score <= 100)//分数隐含的条件
            //{
            //    if (score >= 80)//排除掉80以上的
            //    {
            //        Console.WriteLine("学的不错,继续保持!");
            //    }
            //    else if (score >= 60)//排除60~80之间的
            //    {
            //        Console.WriteLine("刚刚及格,继续加油!");
            //    }
            //    else if (score >= 50)//50~60之间的
            //    {
            //        Console.WriteLine("差一点就及格了!");
            //    }
            //    else//剩下的就是50以下的
            //    {
            //        Console.WriteLine("使劲努力,不要偷懒");
            //    }
            //}
            //else
            //{
            //    Console.WriteLine("输入有误!");
            //}
            //Console.ReadLine();




            //输入三个数,按照从小到大的方式排列打印(使用嵌套)
            Console.Write("请输入第一个数:");
            double x = double.Parse(Console.ReadLine());
            Console.Write("请输入第二个数:");
            double y = double.Parse(Console.ReadLine());
            Console.Write("请输入第三个数:");
            double z = double.Parse(Console.ReadLine());

            if (x < y && x < z)//假设x是最小的
            {
                Console.Write(x + "	");
                if (y < z)
                {
                    Console.Write(y + "	" + z);
                }
                else//z=<y
                {
                    Console.Write(z + "	" + y);
                }
            }
            else if (y < x && y < z)
            {
                Console.Write(y + "	");
                if (x < z)
                {
                    Console.Write(x + "	" + z);
                }
                else//z=<x
                {
                    Console.Write(z + "	" + x);
                }
            }
            else//x==y等于的情况,z是最小的
            {
                if (x == y)
                {
                    if (z > x)
                    {
                        Console.Write(x + "	" + y + "	" + z);
                    }
                    else//z<=x
                    {
                        Console.Write(z + "	" + y + "	" + x);
                    }
                }
                else//x!=y    z是最小的
                {
                    Console.Write(z + "	");
                    if (x < y)
                    {
                        Console.Write(x + "	" + y);
                    }
                    else//y=<x
                    {
                        Console.Write(y + "	" + x);
                    }
                }
            }
            Console.ReadLine();





        }
    }
}
原文地址:https://www.cnblogs.com/tonyhere/p/5469759.html