using namespace std; #include <stdio.h> #include <cmath> #include <iomanip> #include <iostream> #include <cstdio> int main() { int h,m,n,s,a,b,c,k,k1,k2,abc; cin>>abc; a=(abc/3600)%24; b=(abc/60)%60%60; c=(abc%60)%60; cout<<a<<":"<<b<<":"<<c; return 0; } 

1 answer 1

Through std::setfill('0') set the placeholder, through std::setw(N) set the width of the output number. Anything not occupied by the number itself will be filled with a filler character.

 #include <iostream> #include <iomanip> int main() { int i = 42; std::cout << std::setfill('0') << std::setw(8) << i << "\n"; } 

Result:

 00000042