Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int iStart_h, iFinal_m, fStart_h, fFinal_m;
- int nrHours = 0;
- int nrMinutes = 0;
- cin >> iStart_h >> iFinal_m >> fStart_h >> fFinal_m;
- if (iStart_h == fStart_h && iFinal_m == fFinal_m){
- nrHours = 24;
- nrMinutes = 0;
- cout << "O JOGO DUROU " << nrHours << " HORA(S) E " << nrMinutes << " MINUTO(S)" << endl;
- return 0;
- }
- if (fStart_h >= iStart_h){
- nrHours = fStart_h - iStart_h;
- }
- else{ // next day
- nrHours = 24 - (iStart_h - fStart_h);
- }
- if (iFinal_m <= fFinal_m){ // 8 7 9 7
- nrMinutes = fFinal_m - iFinal_m;
- }
- else { // 30 -> 20
- nrMinutes = 60 - (iFinal_m - fFinal_m);
- --nrHours;
- }
- cout << "O JOGO DUROU " << nrHours << " HORA(S) E " << nrMinutes << " MINUTO(S)" << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement