编程每日一题_C程序设计_12-24小时制
程序员文章站
2022-06-12 20:55:04
...
描述:
来源:https://pintia.cn
##### 参考解法:
#include<stdio.h>
int main()
{
int hour=0;
int minute=0;
scanf("%d:%d",&hour,&minute);
//printf("%d\n",minute);
if (hour<12){
printf("%d:%d AM",hour,minute);
}else if (hour==12){
printf("%d:%d PM\n",hour,minute);
}
else if (12<=hour){
hour = hour-12;
//printf("%d\n",hour);
//printf("%d\n",minute);
printf("%d:%d PM\n",hour,minute);
}
return 0;
}