zoukankan      html  css  js  c++  java
  • 利用if else判断几点是什么时间段

     static void Main(string[] args)
            {
                while (true)
                {
                    int a;
                    Random r = new Random();
                    a = r.Next(0,24);
                      Console.WriteLine(a);
                    if (a >= 0 && a < 6)
                    {
                        Console.WriteLine("凌晨"+a+"点");
                    }
                    else if (a >= 6 && a < 12)
                    {
                        Console.WriteLine("上午" + a + "点");
                    }
                    else if (a >= 12 && a < 18)

                    {
                        Console.WriteLine("下午" + (a-12) + "点");
                    }

                    else if (a >= 18 && a <= 24)
                    {
                        Console.WriteLine("晚上" + (a - 12) + "点");
                    }
                    else
                    {
                        Console.WriteLine("对不起,出错了");
                    }

                  }
            }
        }
    }

  • 相关阅读:
    sqlmap使用和X-Forwarded-For注入漏洞测试
    Spring 配置文件中将common.properties文件外置
    git rebase 和 reset的区别
    fatal: Not a valid object name: 'master'.
    Git error on commit after merge
    git 常用命令使用
    git常用命令学习
    关于idea 修改jsp文件后不能生效
    mysql 表被锁处理方案
    Redis 基本操作
  • 原文地址:https://www.cnblogs.com/lk-kk/p/4374276.html
Copyright © 2011-2022 走看看