Time Conversion
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1
Read an integer value, which is the duration in seconds of a certain event in a factory, and inform it expressed in hours:minutes:seconds.
Input
The input file contains an integer N.
Output
Print the read time in the input file (seconds) converted in hours:minutes:seconds like the following example.
Input Sample | Output Sample |
556 | 0:9:16 |
1 | 0:0:1 |
140153 | 38:55:53 |
Solution:
- [tab]
- C
#include<stdio.h> int main(){ int h, m, s, n; scanf("%d", &n); h = n / 3600; m = n % 3600 / 60; s = n % 60; printf("%d:%d:%d\n", h, m, s); return 0; }
- C++
#include <iostream> using namespace std; int main() { int t; cin >> t; int h = t / 3600; t = t - (h * 3600); int m = t / 60; t = t - (m * 60); cout << h << ":" << m << ":" << t << endl; return 0; }