谁能帮我写c语言,是输入一个24小时制的时间,输出12小时制的时间!例输入1605,输出4:05Pm
2008-03-24
展开全部
#include <stdio.h>
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;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<stdio.h>
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);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <stdio.h>
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);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <stdio.h>
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();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询