试题 历届真题 时间显示【第十二届】【省赛】【B组】(蓝桥杯真题)-CSDN博客

59 阅读1分钟

 

这道题感觉主要考察逻辑能力和数学能力

注意要把每年的时间给取模

#include<cstdio>
#define int long long

using namespace std;

signed main(){
	int s;
	scanf("%lld",&s);
	s/=1000;//舍去毫秒 
	s%=86400;//取模到一天内的时间 
	int HH=s/3600;
	int MM=s%3600/60;
	int SS=s%60;
	printf("%02lld:%02lld:%02lld\n",HH,MM,SS);
	return 0;
}