csansoon

P1.12 P34279 Add one second

Sep 19th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main() {
  6.     int h,m,s;
  7.     cin >> h >> m >> s;
  8.     s=s+1;
  9.     if (s>=60) {m=m+1;s=0;}
  10.     if (m>=60) {h=h+1;m=0;}
  11.     if (h>=24) {h=0;}
  12.     if (h<10) {cout << "0" << h << ":";}
  13.     else {cout << h << ":";}
  14.     if (m<10) {cout << "0" << m << ":";}
  15.     else {cout << m << ":";}
  16.     if (s<10) {cout << "0" << s;}
  17.     else {cout << s;}
  18.     cout << endl;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment