万能的网友 麻烦帮我想想用c语言编写出输入时间 判断是一二三四班哪个
答案:1 悬赏:50 手机版
解决时间 2021-11-19 13:52
- 提问者网友:玫瑰园
- 2021-11-18 14:40
万能的网友 麻烦帮我想想用c语言编写出输入时间 判断是一二三四班哪个
最佳答案
- 五星知识达人网友:持酒劝斜阳
- 2021-11-18 15:20
//随便写写
int day = 0;
int class = 1;
char tim[50] = {0};
printf("输入天数(第几天):\n");
scanf("%d", &day);
printf("输入时间hh:mm:\n");
scanf("%s", tim);
if( strcmp("08:30", tim)>0&& strcmp("17:00", tim)<=0){
switch(day%4){
case 0:
class = 1;
break;
case 1:
class = 3;
break;
case 2:
class = 4;
break;
case 3:
class = 2;
break;
}
}else{
switch(day%4){
case 0:
class = 4;
break;
case 1:
class = 2;
break;
case 2:
class = 1;
break;
case 3:
class = 3;
break;
}
}
printf("%d班上班\n", class);
int day = 0;
int class = 1;
char tim[50] = {0};
printf("输入天数(第几天):\n");
scanf("%d", &day);
printf("输入时间hh:mm:\n");
scanf("%s", tim);
if( strcmp("08:30", tim)>0&& strcmp("17:00", tim)<=0){
switch(day%4){
case 0:
class = 1;
break;
case 1:
class = 3;
break;
case 2:
class = 4;
break;
case 3:
class = 2;
break;
}
}else{
switch(day%4){
case 0:
class = 4;
break;
case 1:
class = 2;
break;
case 2:
class = 1;
break;
case 3:
class = 3;
break;
}
}
printf("%d班上班\n", class);
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯