c语言输入一天24小时的时间输出对应时段使用switch语句
[0-4]点为深夜,(4-6]凌晨,(6-8]早晨,(8-12]上午,(12-18]下午,(18-0]为晚上...
[0-4]点为深夜,(4-6]凌晨,(6-8]早晨,(8-12]上午,(12-18]下午,(18-0]为晚上
展开
1个回答
展开全部
#include<stdio.h>
int main(void){
int hour;
prntf("请输入小时数:")
scanf("%d",&hour);
switch(hour){
case 1:
case 2:
case 3:
case 4:
printf("深夜");break;
case 5:
case 6:
printf("凌晨");break;
case 7:
case 8:
printf("早晨");break;
case 9:
case 10:
case 11:
case 12:
printf("上午");break;
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
printf("下午");break;
case 19:
case 20:
case 21:
case 22:
case 23:
case 0:
printf("晚上");
}
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询