题目地址
https://www.lanqiao.cn/problems/1452/learning
c++代码
#include <iostream>
#include<iomanip>
using namespace std;
int main()
{
long long ti;
cin>>ti;
int day;
ti /=1000;
day = ti % (60 * 60 * 24);
int h,m,s;
h = day / (60 * 60);
m = (day - (h * 60 * 60)) / 60;
s = day - h * 60 * 60 - m *60;
cout<<setw(2)<<setfill('0')<<h<<":"<<setw(2)<<setfill('0')<<m<<":"<<setw(2)<<setfill('0')<<s<<endl;
return 0;
}
注意:
如果h不足两位,要补充 0
用setw(2)<<setfill(‘0’)<<h;
cout<<setw(2)<<setfill('0')<<h;