Advertisement
Josif_tepe

Untitled

Mar 19th, 2021
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int h1, m1;
  7.     int h2, m2;
  8.     cin >> h1 >> m1;
  9.     cin >> h2 >> m2;
  10.    
  11.     int min1 = h1 * 60 + m1;
  12.     int min2 = h2 * 60 + m2;
  13.    
  14.     if((m2 < m1 and h2 == h1) or h1 > h2) {
  15.         min2 += 24 * 60;
  16.     }
  17.    
  18.     int h3 = (min2 - min1) / 60;
  19.     int m3 = (min2 - min1) % 60;
  20.     if(h3 < 10) {
  21.         cout << "0";
  22.     }
  23.     cout << h3 << ":";
  24.     if(m3 < 10) {
  25.         cout << "0";
  26.     }
  27.     cout << m3 << endl;
  28.     return 0;
  29. }
  30. // 19 --> 20
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement