Advertisement
Guest User

Untitled

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