zoukankan      html  css  js  c++  java
  • 假期结束------印象加深

    Console.Write("请输入年份:");
                     int y = int.Parse(Console.ReadLine());
                     if (y > 0 && y <= 9999)
                     {
                         Console.Write("请输入月份:");
                         int m = int.Parse(Console.ReadLine());
                         if (m > 0 && m <= 12)
                         {
                             Console.Write("请输入日:");
                             int d = int.Parse(Console.ReadLine());
                             if (d > 0 && d <= 31)
                             {
                                 if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)
                                 {
                                     Console.WriteLine("您输入的日期为:{0}年{1}月{2}日", y, m, d);
                                 }
                                 else if (m == 4 || m == 6 || m == 9 || m == 11)
                                 {
                                     if (d < 31)
                                     {
                                         Console.WriteLine("您输入的日期为:{0}年{1}月{2}日", y, m, d);
                                     }
                                     else
                                     {
                                         Console.WriteLine("你的输入有误!");
                                     }
                                 }
                                 else
                                 {
                                     if (d < 29)
                                     {
                                         Console.WriteLine("您输入的日期为:{0}年{1}月{2}日", y, m, d);
                                     }
                                     else if (d == 29 && (y % 4 == 0 && y % 100 != 0 || y % 400 == 0))
                                     {
                                         Console.WriteLine("您输入的日期为:{0}年{1}月{2}日", y, m, d);
                                     }
                                     else
                                     {
                                         Console.WriteLine("你的输入有误!");
                                     }
                                 }
                             }
                             else
                             {
                                 Console.WriteLine("你的输入有误!");
                             }
                         }
                         else{
                             Console.WriteLine("您输入的月份有误!");
                         }
                     }
                     else
                     {
                         Console.WriteLine("您输入的年份有误!");
                     }
                     Console.ReadLine();
    这题充分运用了if else 的嵌套 看着麻烦其实也没很麻烦,理顺逻辑顺序即可,个人感觉只要按部就班、严谨就好,人会取巧而使事态发展到别的方向,但计算机不会!
    今天虽然只是复习,但感觉收获不少。
  • 相关阅读:
    Cassandra 分页 读取数据
    cassandra高级操作之索引、排序以及分页
    cassandra 可视化工具
    SpringBoot集成Cassandra参考文章
    022 android studio 首次启动时默认的sdk安装路径
    021 Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout)
    020 本机Gradle目录 Could not find com.android.tools.build:gradle:4.1
    019 Android Studio打开XML文件Design显示Waiting for build to finish
    018 Could not download espresso-core-3.2.0.aar (androidx.test.espresso:espresso-core:3.2.0)
    017 Android Studio is using the following JDK location when running Gradle:
  • 原文地址:https://www.cnblogs.com/shadow-wolf/p/5940272.html
Copyright © 2011-2022 走看看