谁能帮我写c语言,是输入一个24小时制的时间,输出12小时制的时间!例输入1605,输出4:05Pm
答案:4 悬赏:30 手机版
解决时间 2021-02-25 16:06
- 提问者网友:沉默的哀伤
- 2021-02-25 00:56
谁能帮我写c语言,是输入一个24小时制的时间,输出12小时制的时间!例输入1605,输出4:05Pm
最佳答案
- 五星知识达人网友:风格不统一
- 2021-02-25 02:15
#include
int main(void)
{
int h24;
scanf("%d",&h24);
printf("%d:%02d\t%s\n",h24/100<=12?h24/100:h24/100-12,
h24%100,
h24/100<12?"AM":"PM");
return 0;
}
int main(void)
{
int h24;
scanf("%d",&h24);
printf("%d:%02d\t%s\n",h24/100<=12?h24/100:h24/100-12,
h24%100,
h24/100<12?"AM":"PM");
return 0;
}
全部回答
- 1楼网友:平生事
- 2021-02-25 04:32
#include
int main()
{ int hour24,hour,min;
printf("please input 24hour time:");
scanf("%d",&hour24);
hour=hour24/100;
min=hour24-hour*100;
if(hour<12)
printf("%d:%2dAM", hour);
else
printf("%d:%2dPM", hour-12,min);
getch();
}
int main()
{ int hour24,hour,min;
printf("please input 24hour time:");
scanf("%d",&hour24);
hour=hour24/100;
min=hour24-hour*100;
if(hour<12)
printf("%d:%2dAM", hour);
else
printf("%d:%2dPM", hour-12,min);
getch();
}
- 2楼网友:愁杀梦里人
- 2021-02-25 03:38
#include
main()
{int H,h,i;
scanf("%d",&H);
if(H/100>12)h=H/100%12;
else h=H/100;
if(H/100/12.0>1)printf("%d:%02dPm",h,H%100);
else printf("%d:%02dAm",h,H%100);
}
main()
{int H,h,i;
scanf("%d",&H);
if(H/100>12)h=H/100%12;
else h=H/100;
if(H/100/12.0>1)printf("%d:%02dPm",h,H%100);
else printf("%d:%02dAm",h,H%100);
}
- 3楼网友:未来江山和你
- 2021-02-25 03:22
#include
void main()
{ int hour24;
printf("please input 24hour time:");
scanf("%d",hour24);
hour12=hour24-12;
if(hour24>12)
printf("%d",AM hour12);
else printf("%d",PM hour12);
}
void main()
{ int hour24;
printf("please input 24hour time:");
scanf("%d",hour24);
hour12=hour24-12;
if(hour24>12)
printf("%d",AM hour12);
else printf("%d",PM hour12);
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯