我这段写的怎么分钟总是显示错误啊,是哪里的问题 求大神指教。int main(void)
{
int h,m,a;
a=h-12;
printf("Enter a 24-hour time:");
scanf("%d:%d",&h,&m);
switch(h)
{
case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12:
printf("Equivalent 12-hour time:%d:%d AM",h, m);break;
case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23:
printf("Equivalent 12-hour time:%d:%d PM",a,m);break;
case 0 :
printf("Equivalent 12-hour time:12:%d AM",m);break;
}
return 0;
}
2 回答
望远
TA贡献1017条经验 获得超1032个赞
#include<stdio.h>
int main(void) {
int h,m,a;
printf("Enter a 24-hour time:");
scanf("%d:%d",&h,&m);
a=h-12;
switch(h) {
case 1: case 2:
case 3: case 4:
case 5: case 6:
case 7: case 8:
case 9: case 10:
case 11: case 12:
printf("Equivalent 12-hour time:%d:%d AM\n",h, m);break;
case 13: case 14:
case 15: case 16:
case 17: case 18:
case 19: case 20:
case 21: case 22:
case 23:
printf("Equivalent 12-hour time:%d:%d PM\n",a,m);break;
case 0 :
printf("Equivalent 12-hour time:12:%d AM",m);break;
}
return 0; }
这样吗??
- 2 回答
- 0 关注
- 1580 浏览
添加回答
举报
0/150
提交
取消