Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int h1, m1;
- int h2, m2;
- cin >> h1 >> m1;
- cin >> h2 >> m2;
- int min1 = h1 * 60 + m1;
- int min2 = h2 * 60 + m2;
- if((m2 < m1 and h2 == h1) or h1 > h2) {
- min2 += 24 * 60;
- }
- int h3 = (min2 - min1) / 60;
- int m3 = (min2 - min1) % 60;
- if(h3 < 10) {
- cout << "0";
- }
- cout << h3 << ":";
- if(m3 < 10) {
- cout << "0";
- }
- cout << m3 << endl;
- return 0;
- }
- // 19 --> 20
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement