《零基础学C#》第六章-实例04:输出天气——练习1

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wtxhai/article/details/88658800
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Example604_01
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime four = new DateTime(2017, 5, 1, 4, 0, 0);
            DateTime eight = new DateTime(2017, 5, 1, 8, 0, 0);
            DateTime twelve = new DateTime(2017, 5, 1, 12, 0, 0);
            DateTime sixteen = new DateTime(2017, 5, 1, 16, 0, 0);
            DateTime twenty = new DateTime(2017, 5, 1, 20, 0, 0);
            DateTime twentyfour = new DateTime(2017, 5, 1, 0, 0, 0);
            // 输出一天的整体天气情况
            Console.WriteLine(string.Format("{0:D}  天气预报:晴  7°——18°  微风转3-4级", four));
            // 输出4点的天气
            Console.WriteLine(string.Format("{0:t}   天气预报:晴  9°   微风", four));
            // 输出8点的天气
            Console.WriteLine(string.Format("{0:t}   天气预报:晴  12°  微风", eight));
            // 输出12点的天气
            Console.WriteLine(string.Format("{0:t}  天气预报:晴  18°  微风", twelve));
            // 输出16点的天气
            Console.WriteLine(string.Format("{0:t}  天气预报:晴  16°  西风3-4级", sixteen));
            // 输出20点的天气
            Console.WriteLine(string.Format("{0:t}  天气预报:晴  12°  西风3-4级", twenty));
            // 输出0点的天气
            Console.WriteLine(string.Format("{0:t}   天气预报:晴  7°   微风", twentyfour));
            Console.ReadLine();
        }
    }
}

猜你喜欢

转载自blog.csdn.net/wtxhai/article/details/88658800