654. Time conversion
Read an integer value. It is the duration (in seconds) of an event in the factory. Please convert it to hours: minutes: seconds.
Input format
Enter an integer N.
Output format
The converted time is expressed in the format of "hours:minutes:seconds".
data range
1≤N≤10000001≤N≤1000000
Input sample:
556
Sample output:
0:9:16
/*秒数换算成标准格式有固定公式:
小时 = 总秒数 / 3600;
分钟 = 总秒数 % 3600 / 60;
秒数 = 总秒数 % 60;*/
#include <cstdio>
#include <cmath>
int main()
{
int n, h ,m, s;
scanf("%d", &n);
h = n / (60 * 60);
m = (n - h * (60 * 60)) / 60;
s = (n - h * (60 * 60)) % 60;
printf("%d:%d:%d\n", h, m, s);
return 0;
}