[Blue Bridge Cup] Time Display C++

insert image description here

== What you need to pay attention to in this question is that the input time is in milliseconds and the range is 10 to the 18th power, so you need to define a long integer ==

#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    
	long long num;
	cin>>num;
	long long ss;
	int h = 0,m = 0,s = 0;
	//将毫秒变成秒
	ss = num/1000;
	h = (ss/3600)%24;
	m = (ss/60)%60;
	s = ss%60;

	printf("%02d:%02d:%02d",h,m,s);
	return 0;
}

Guess you like

Origin blog.csdn.net/qq_63524016/article/details/129245860