Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int x1,y1,x2,y2,sum,z,x,i,f;
  6.  
  7. cin>>x1>>y1>>x2>>y2;
  8. if(x1>=0 && x1<24 && x2>=0 && x2<24 && y1>=0 && y1<60 && y2>=0 &&y1<60)
  9. {
  10.  
  11. if(x1<x2 )
  12. {
  13. sum=(x2*60+y2)-(x1*60+y1);
  14. if(sum>60){
  15. z=sum/60;
  16. x=sum-(z*60);
  17.  
  18. cout<<"O JOGO DUROU "<<z<<" HORA(S) E "<<x<<" MINUTO(S)"<<endl;
  19. }
  20. else{
  21. z=sum/60;
  22. x=sum;
  23. cout<<"O JOGO DUROU "<<z<<" HORA(S) E "<<x<<" MINUTO(S)"<<endl;
  24. }
  25. }
  26. else if(x1==x2 && y2>y1){
  27. sum=(x2*60+y2)-(x1*60+y1);
  28. z=sum/60;
  29. x=sum;
  30. cout<<"O JOGO DUROU "<<z<<" HORA(S) E "<<x<<" MINUTO(S)"<<endl;
  31.  
  32. }
  33.  
  34.  
  35.  
  36. else
  37. {
  38. i=(24*60)-(x1*60+y1);
  39. f=(x2*60+y2);
  40. sum=(i+f);
  41. if(sum>60){
  42. z=sum/60;
  43. x=sum-(z*60);
  44.  
  45. cout<<"O JOGO DUROU "<<z<<" HORA(S) E "<<x<<" MINUTO(S)"<<endl;
  46. }
  47.  
  48. }
  49.  
  50.  
  51. }
  52.  
  53.  
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement