• 0722语句


    //语句的分类
                //顺序语句,分支语句(选择语句) ,循环语句

                //分枝
                //格式1   if(){}
                //int a = 6;
                //  if(a<=100&&a>=0)
                //  {
                //      Console.WriteLine("这个数是100以内的数");


                //  }
                //  Console.WriteLine(a);
                //  Console.ReadLine();

                //格式2  if(){} else{}
                //如果if满足,走if
                //如果if不满足,就一定走else

                //Console.Write("请输入一个数字");
                //int a = int.Parse(Console.ReadLine());
                //if (a >= 10 && a < 100)
                //{
                //    Console.WriteLine("您输入的是一个两位整数");
                //}
                //else
                //{
                //if(a<10){
                //    Console.Write("您输入的不是两位数");
                //}
                //    else
                //    {
                //     Console.WriteLine("您输入的数大于等于100");
                //    }
                //}
                //    Console.ReadLine();


                //格式3 if(){}else   if(){}    else{}   多选一
                //只要上面有一个if或else if满足,就执行
                //从它开始下面不再判断
                //Console.Write("请输入一个月份:");
                //int a = int.Parse(Console.ReadLine());
                //if (a > 2 && a < 6)
                //{
                //    Console.WriteLine("您输入的是春天的月份");
                //}
                //else if (a > 5 && a < 9)
                //{
                //    Console.WriteLine("您输入的是夏天的月份");
                //}
                //else if (a > 8 && a < 12)
                //{
                //    Console.WriteLine("您输入的是秋天的月份");
                //}
                //else if (a == 12 || a == 1 || a == 2)
                //{
                //    Console.WriteLine("您输入的是冬天的月份");
                //}

                //else
                //{
                //    Console.WriteLine("您输入的有误");
                //}
                //    Console .ReadLine();


                //格式4  if的嵌套
                //首先规定大的范围,再进去判断小的情况
                //    Console.Write("请输入一个月份:");
                //    int a = int.Parse(Console.ReadLine());
                //    if(a>0&&a<13)
                //{
                //    if (a > 2 && a < 6)
                //{
                //    Console.WriteLine("您输入的是春天的月份");
                //}
                //else if (a > 5 && a < 9)
                //{
                //    Console.WriteLine("您输入的是夏天的月份");
                //}
                //else if (a > 8 && a < 12)
                //{
                //    Console.WriteLine("您输入的是秋天的月份");
                //}
                //    else if (a == 12 || a == 1 || a == 2)
                //{
                //        Console.WriteLine("您输入的是冬天的月份");
                //}
                //}
                //else
                //{
                // Console.WriteLine("您输入有误");
                //}
                // Console.ReadLine();

                //输入学生姓名,输入考试成绩
                //若是100,【恭喜**,满分通过!】
                //若是大于等于80小于100.【**,你很优秀,请继续保持】
                //若是大于等于60小于80,【**成绩良好】
                //大于等于50小于60,【**就差一点点,下次一定要至少及格】
                //小于50【**你是笨蛋吗】
                //Console.Write("请输入您的姓名:");
                //string name = Console.ReadLine();
                //Console.Write("请输入您的成绩:");
                //double a = double.Parse(Console.ReadLine());
                //if (a == 100)
                //{
                //    Console.WriteLine("恭喜" + name + ",满分通过!");
                //}
                //else if (a >= 80 && a < 100)
                //{
                //    Console.WriteLine(name + ",你很优秀,请继续保持!");
                //}
                //else if (a >= 60 && a < 80)
                //{
                //    Console.WriteLine(name + "成绩良好");
                //}
                //else if (a >= 50 && a < 60)
                //{
                //    Console.WriteLine(name + "就差一点点,下次一定要至少及格!");
                //}
                //else
                //{
                //    Console.WriteLine(name + "你是笨蛋吗?");
                //}
                //Console.ReadLine();

                //请输入一个年份,判断年份是不是闰年
                //year%4==0&&year%100!=0
                //year%400==0
                //Console.Write("请输入一个年份:");
                //int year = int.Parse(Console.ReadLine());
                //if(year>=0&&year<=9999)
                //{
                //    if (year % 4 == 0 && year % 100 != 0||year%400==0 )
                //    {
                //            Console.WriteLine("您输入的是闰年!");

                //    }
                //    else
                //    {
                //        Console.WriteLine("您输入的不是闰年!");
                //    }
                //}
                //else
                //{
                //    Console.WriteLine("输入有误!");
                //}
                //Console.ReadLine();

                //分别输入年月日,判断日期格式是否正确
                //Console.Write("请输入年份:");
                //int year = int.Parse(Console.ReadLine());
                //if (year >= 0 && year <= 9999)
                //{
                //    Console.Write("请输入月份:");
                //    int month = int.Parse(Console.ReadLine());
                //    if (month >= 1 && month <= 12)
                //    {
                //        Console.Write("请输入日期:");
                //        int day = int.Parse(Console.ReadLine());
                //        if (day >= 1 && day <= 31)
                //        {
                //            if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
                //            {
                //                Console.WriteLine("您输入的日期正确,日期为:" + year + "年" + month + "月" + day + "日。");
                //            }
                //            else if (month == 4 || month == 6 || month == 9 || month == 11)
                //            {
                //                string d = day <= 30 ? "您输入的日期正确,日期为:" + year + "年" + month + "月" + day + "日。" : "日期格式有误!";
                //                Console.WriteLine(d);
                //            }
                //            else if (month == 2)
                //            {
                //                if (day >= 30)
                //                {
                //                    Console.WriteLine("日期格式有误!");
                //                }
                //                else if (day == 28)
                //                {
                //                    Console.WriteLine("您输入的日期正确,日期为:" + year + "年" + month + "月" + day + "日。");
                //                }

                //                else if (day == 29)
                //                {
                //                    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
                //                    {
                //                        Console.WriteLine("您输入的日期正确,日期为:" + year + "年" + month + "月" + day + "日。");
                //                    }
                //                    else
                //                    {
                //                        Console.WriteLine("日期格式有错!");
                //                    }
                //                }
                //            }

                //            else
                //            {
                //                Console.WriteLine("日期格式有错!");
                //            }

                //        }
                //        else
                //        {
                //            Console.WriteLine("您输入的日期有误!");
                //        }
                //    }
                //    else
                //    {
                //        Console.WriteLine("您输入的月份有误!");
                //    }
                //}
                //else
                //{
                //    Console.WriteLine("您输入的年份有误!");
                //}
                //Console.ReadLine();

                //1.方程ax2+bx+c=0一元二次方程。求根
                //△=b2-4ac;若△<0方程无实根
                //若△>0,方程有两个不相同的实根x1   x2
                //若△=0,方程有两个相同的实根
                //Console.Write("请输入a的值:");
                //double a = double.Parse(Console.ReadLine());
                //if (a != 0)
                //{
                //    Console.Write("请输入b的值:");
                //    double b = double.Parse(Console.ReadLine());
                //    Console.Write("请输入c的值:");
                //    double c = double.Parse(Console.ReadLine());
                //    double e = b * b - 4 * a * c;
                //    if (e < 0)
                //    {
                //        Console.WriteLine("方程无实根");
                //    }
                //    else if (e > 0)
                //    {
                //        Console.WriteLine("方程有两个实根,分别为x1=" + ((-b + Math.Sqrt(e)) / (2 * a)) + ",x2=" + ((-b - Math.Sqrt(e)) / (2 * a)));
                //    }
                //    else
                //    {
                //        Console.WriteLine("方程有两个相等实数根,为x1=x2=" + ((-b + Math.Sqrt(e)) / (2 * a)));
                //    }
                //}
                //else
                //{
                //    Console.WriteLine("非一元二次方程");
                //}
                //Console.ReadLine();

                //2.有一组函数:y = x (x<1);y = 2x -1  (1<=x<10); y = 3x-11  (x>=10)。
                // 括号内是x的满足条件。
                // 实现功能,随意输入一个x值,输出y的值
                //Console.Write("请输入x的值:");
                //double x = double.Parse(Console.ReadLine());
                //if(x<1)
                //{
                //    Console.WriteLine("得到的y值为:"+x);
                //}
                //else if (x >= 1 && x < 10)
                //{
                //    Console.WriteLine("得到的y值为:" + (2 * x - 1));
                //}
                //else
                //{
                //    Console.WriteLine("得到的y值为:"+(3*x-11));
                //}
                //Console.ReadLine();

                //3.输入整数a和b,若a2+b2大于100,则输出a2+b2百位以上数字,否则输出两数之和
                //Console.Write("请输入a的值:");
                //double a = double.Parse(Console.ReadLine());
                //Console.Write("请输入b的值:");
                //double b = double.Parse(Console.ReadLine());
                //double c=a*a+b*b;
                //if (c > 100)
                //{
                //    Console.WriteLine(c);
                //}
                //else
                //{
                //    Console.WriteLine(a+b);
                //}
                //Console.ReadLine();

                //4.相亲过程:你有房子么?你有钱么?你有能力么?
                // 【结婚吧】【先买房子在结婚】【先赚钱再买房子再结婚】都没有【拜拜~~】
                // 利用if嵌套做相亲过程
                //Console.Write("你有房子吗?");
                //string ss = Console.ReadLine();
                //if (ss == "没有")
                //{
                //    Console.Write("你有钱吗?");
                //    string a = Console.ReadLine();
                //    if (a == "没有")
                //    {
                //        Console.Write("你有能力吗?");
                //        string b = Console.ReadLine();
                //        if (b == "没有")
                //        {
                //            Console.WriteLine("拜拜~");
                //        }
                //        else
                //        {
                //            Console.WriteLine("先赚钱再买房子再结婚!");
                //        }
                //    }
                //    else
                //    {
                //        Console.WriteLine("先买房子在结婚");
                //    }
                //}
                //else
                //{
                //    Console.WriteLine("结婚吧!");
                //}

                //Console.ReadLine();


                //switch case   多选一
                //Console.WriteLine("1.汉堡包");
                //Console.WriteLine("2.鸡腿");
                //Console.WriteLine("3.鸡米花");
                //Console.WriteLine("4.鸡肉卷");

                //Console.Write("请输入你想要的物品的编号:");
                //int a = int.Parse(Console.ReadLine());

                //switch (a)
                //{
                //    case 1:
                //        Console.WriteLine("您选择的是汉堡包!");
                //        break;//跳出:跳出最近的花括号
                //    case 2:
                //        Console.WriteLine("您选择的是鸡腿!");
                //        break;//跳出:跳出最近的花括号
                //    case 3:
                //        Console.WriteLine("您选择的是鸡米花!");
                //        break;//跳出:跳出最近的花括号
                //    case 4:
                //        Console.WriteLine("您选择的是鸡肉卷!");
                //        break;//跳出:跳出最近的花括号
                //    default://意思是相当于else,表示以上的值都不对
                //        Console.WriteLine("输入错误!");
                //        break;
                //}
                //Console.ReadLine();


               // Console.Write("请输入月份:");
               // int month = int.Parse(Console.ReadLine());
               // Console.Write("请输入日期:");
               // int day = int.Parse(Console.ReadLine());
               //int m1=31,m2=28,m3=31,m4=30,m5=31,m6=30,m7=31,m8=31,m9=30,m10=31,m11=30;
               //  int num;
               //  switch (month)
               //  {
               //      case 1: Console.WriteLine("第" + day + "天");
               //          break;
               //      case 2: Console.WriteLine("第" + (day+m1) + "天");
               //          break;
               //      case 3: Console.WriteLine("第" + (day+m1+m2) + "天");
               //          break;
               //      case 4: Console.WriteLine("第" + (day+m1+m2+m3) + "天");
               //          break;
               //      case 5: Console.WriteLine("第" + (day+m1+m2+m3+m4) + "天");
               //          break;
               //      case 6: Console.WriteLine("第" + (day+m1+m2+m3+m4+m5) + "天");
               //          break;
               //      case 7: Console.WriteLine("第" + (day+m1+m2+m3+m4+m5+m6) + "天");
               //          break;
               //      case 8: Console.WriteLine("第" + (day+m1+m2+m3+m4+m5+m6+m7) + "天");
               //          break;
               //      case 9: Console.WriteLine("第" + (day+m1+m2+m3+m4+m5+m6+m7+m8) + "天");
               //          break;
               //      case 10: Console.WriteLine("第" + (day+m1+m2+m3+m4+m5+m6+m7+m8+m9) + "天");
               //          break;
               //      case 11: Console.WriteLine("第" + (day+m1+m2+m3+m4+m5+m6+m7+m8+m9+m10) + "天");
               //          break;
               //      case 12: Console.WriteLine("第" + (day+m1+m2+m3+m4+m5+m6+m7+m8+m9+m10+m11) + "天");
               //          break;

               //      default:
               //           Console .WriteLine("您输入的有误!");
               //          break;
               //  }
               //          Console.ReadLine();

  • 相关阅读:
    投资理财知识小结1
    iOS中异常处理机制使用小结
    iOS中NSBundle使用小结
    ant design vue a-cascader 级联选择器 数据回显
    hbase数据存储及数据访问原理
    第15章: Prometheus监控Kubernetes资源与应用
    第14章:部署Java网站项目案例
    第13章:Kubernetes 鉴权框架与用户权限分配
    第12章:有状态应用部署
    第11章:Pod数据持久化
  • 原文地址:https://www.cnblogs.com/a12110303043/p/5695756.html
Copyright © 2020-2023  润新知