<stdio.h>
int
main()
{
int
h,m,s
while(scanf("%d:%d:%d",&h,&m,&s))
{
if(h!=12)
{
h=h%12
}
printf("PM:%02d:%02d:%02d\n",h,m,s)
}
}
未通过,是因为但h,m,s是个位数时,比如我输入12:00:00,输出的是AM:12:0:0,而不是AM:12:00:00,怎么办有什么办法?
对你这个问题
格式化输出就可以了...
看我的代码...
符合你的要求...
#include<stdio.h>main()
{
int t,th,tm,ts
while(1){
scanf("%d",&t)
th=t/3600
tm=(t-th*3600)/60
ts=t-th*3600-tm*60
printf("%02d:%02d:%02d\n",th,tm,ts)
}
}
如图所示,望采纳。。。。。。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)