Seconds to Time
Completed
Read a number of seconds and print HH:MM:SS with leading zeros, using setw(2) and setfill('0').
Input
One integer 0–86399.
Output
One line.
Example
Input
3725
Output
01:02:05
Editor
C++
Hints
setfill('0') pads with zeros instead of spaces.
setw(2) must be repeated before each number.
Solution explanation
setfill stays in effect; setw applies to one item only.
Show solution
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int t;
cin >> t;
cout << setfill('0') << setw(2) << t / 3600 << ":" << setw(2) << t % 3600 / 60 << ":" << setw(2) << t % 60 << "\n";
return 0;
}