Advertisement
Guest User

Untitled

a guest
Aug 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int iStart_h, iFinal_m, fStart_h, fFinal_m;
  8.     int nrHours = 0;
  9.     int nrMinutes = 0;
  10.     cin >> iStart_h >> iFinal_m >> fStart_h >> fFinal_m;
  11.  
  12.     if (iStart_h == fStart_h && iFinal_m == fFinal_m){
  13.         nrHours = 24;
  14.         nrMinutes = 0;
  15.         cout << "O JOGO DUROU " << nrHours << " HORA(S) E " <<  nrMinutes << " MINUTO(S)" << endl;
  16.         return 0;
  17.     }
  18.  
  19.  
  20.     if (fStart_h >= iStart_h){
  21.         nrHours = fStart_h - iStart_h;
  22.     }
  23.     else{ // next day
  24.         nrHours = 24 - (iStart_h - fStart_h);
  25.     }
  26.  
  27.     if (iFinal_m <= fFinal_m){ // 8 7 9 7
  28.         nrMinutes = fFinal_m - iFinal_m;
  29.  
  30.     }
  31.     else { // 30 -> 20
  32.         nrMinutes = 60 - (iFinal_m - fFinal_m);
  33.         --nrHours;
  34.     }
  35.  
  36.     cout << "O JOGO DUROU " << nrHours << " HORA(S) E " <<  nrMinutes << " MINUTO(S)" << endl;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement