首页 > 其他 > 详细

用函数将闹钟练一练

时间:2015-04-12 22:37:38      阅读:318      评论:0      收藏:0      [点我收藏+]

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

namespace 用函数把闹钟习题练一练无返回值
{
    class Program
    {
        public void naozhong(DateTime dt,DateTime nz)
        {
            for (int i = 0; i <= 1000; i++)
            {
                dt = dt.AddMinutes(1);
                Console.WriteLine(dt.ToShortTimeString());
                if (dt.ToShortTimeString().Equals(nz.ToShortTimeString()))
                {
                    Console.WriteLine("到点了。");
                    Console.WriteLine("是否关闭闹钟(Y/N)");
                    string x = Console.ReadLine();
                    if (x == "Y")
                    {
                        break;
                    }
                    else
                    {
                        nz = nz.AddMinutes(5);
                    }
                }
            }
        }
        static void Main(string[] args)
        {
                DateTime dt = DateTime.Now;
                Console.WriteLine(dt);
                DateTime nz = Convert.ToDateTime("2015-4-12 12:00");
                new Program().naozhong(dt,nz);
                Console.ReadLine();
           
        }
    }
}

用函数将闹钟练一练

原文:http://www.cnblogs.com/lk-kk/p/4420598.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!