• 关于闹钟的题


    static void Main(string[] args)
            {
              
                    DateTime dt = DateTime.Now;
                    Console.WriteLine(dt);
                    DateTime nz = Convert.ToDateTime("2015-4-2  17:00"); //将nz的时间转换为电脑能识别的时间
                 
                    for (int i = 1; i < 1000; i++)
                    {
                       
                      dt = dt.AddMinutes(1); //系统时间加1分钟
                         Console.WriteLine(dt.ToShortTimeString());   //输出的时间为短的时间,就是只有时间,没有日期
                        
                        if(nz.ToShortTimeString().Equals(dt.ToShortTimeString()))  //两个时间相比的公式!!  这是相等的公式 Equals 相等的意思
                        {
                            Console.WriteLine("到点了");
                            Console.WriteLine("是否关闭闹钟(Y/N)");
                            string b = Console.ReadLine();
                            if (b.ToUpper()=="N")  //将字母转换为大写
                            {
                                nz = nz.AddMinutes(5); //闹钟的时间在原来的基础上加5分钟
                           
                            }
                            else
                            {
                                Console.WriteLine("闹钟已停");
                                break;
                            }
                        }

                    }
                Console.ReadLine();
                   
               
            }

  • 相关阅读:
    [Leetcode Weekly Contest]285
    [Leetcode Weekly Contest]286
    [Leetcode Weekly Contest]284
    [Leetcode Weekly Contest]287
    阿凡达机器人简介
    PS常用组合键
    PhotoshopCS6 后退多步
    如何卸载Creative Cloud?
    五月实际
    SSO 方案演进
  • 原文地址:https://www.cnblogs.com/lk-kk/p/4388107.html
Copyright © 2020-2023  润新知