时间显示【第十二届】【省赛】【B组】

#include<stdio.h>

int main()
{
	long long n,temp;
	scanf("%lld",&n);
	temp=n%(24*60*60*1000);//对一天共有的毫秒取余 
	int h,m,s;
	h=temp/(1000*60*60);
	m=temp%(1000*60*60)/(1000*60);
	s=temp%(1000*60)/1000;
	if(h<10&&h>0)
		printf("0%d:",h);
	else if(h==0) printf("00:");	
	else printf("%2d:",h);
	
	if(m<10&&m>0)
		printf("0%d:",m);
	else if(m==0) printf("00:");	
	else printf("%2d:",m);
	
	if(s<10&&s>0)
		printf("0%d",s);
	else if(s==0) printf("00");	
	else printf("%2d",s);
	return 0;
 }

猜你喜欢

转载自blog.csdn.net/m0_60817176/article/details/122252112