返回题解分享
讨论 / 题解分享/ 帖子详情

时间显示(编程题) - 题解

#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;


int main()
{
	int a,b,c;
	long long n;
	cin>>n;
	n=n/1000%(3600*24);  
    
    //毫秒换成秒,%一天的秒数,使n数量小于一天

	a=n/3600;   //多少小时
	n%=3600;    //分钟加上秒的总时间
	b=n/60;     //分钟
	c=n%60;     //秒
printf("%02d:%02d:%02d",a,b,c);  //02是为了始终有两位数字
	return 0;
}
0 回复 0 转发 0 喜欢 3 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!