while (true)
{
Console.Write("请输入一个时间(24小时制):");
//string s = Console.ReadLine();
int hour = Convert.ToInt32(Console .ReadLine ());
if(hour >= 0 && hour < 6)
{
Console.Write("凌晨" + hour + "点");
}
else if(hour >= 6 && hour < 13)
{
Console.Write("上午" + hour + "点");
}
else if(hour >= 13 && hour < 19)
{
hour = hour - 12;
Console.Write("下午" + hour + "点");
}
else if(hour >= 19 && hour < 24)
{
hour = hour - 12;
Console.Write("晚上" + hour + "点");
}
else
{
Console.Write("不可识别的时间");
}
Console.ReadLine(); }
时间: 2024-10-20 02:04:28