作业1.老狼几点了。凌晨,上午,下午,晚上。

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 
 6 namespace ConsoleApplication1
 7 {
 8     class Class1
 9     {
10         static void Main(string[] arge)
11         {
12             Console.Write("老狼老狼几点了?");
13             string s = Console.ReadLine();
14             int hour = Convert.ToInt32(s);
15 
16             if (hour >= 0 && hour < 6)
17             {
18                 Console.WriteLine("凌晨"+hour+"点了");
19             }
20             else if (hour >=6 && hour <=12)
21             {
22                 Console.WriteLine("上午"+hour+"点了");
23             }
24             else if (hour > 12 && hour <= 18)
25             {
26                 hour -= 12;
27                 Console.WriteLine("下午"+hour+"点了");
28 
29             }
30             else if (hour > 18 && hour < 24)
31             {
32                 hour -= 12;
33                 Console.WriteLine("晚上" + hour + "点了");
34             }
35             else
36             {
37                 Console.WriteLine("输入的时间不对");
38             }
39 
40 
41 
42         }
43     }
44 }
原文地址:https://www.cnblogs.com/viven/p/4178971.html