Advertisement
Guest User

Pretvornik casa hms - s in razlika casov

a guest
Mar 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int hms_v_sec (int h,int m,int s)
  6. {
  7. return h*3600+m*60+s;
  8. }
  9. int hms_v_sec1 (int h1, int m1,int s1)
  10. {
  11. return h1*3600+m1*60+s1;
  12. }
  13. void sec_v_hms (int time, int &h, int &m, int &s)
  14. {
  15. h=time/3600;
  16. time=time%3600;
  17. m=time/60;
  18. time=time%60;
  19. s=time;
  20.  
  21. }
  22. int main()
  23. {
  24. int h1,m1,s1,h,m,s,time,hour,min,sec,skupno,h3,m3,s3;
  25. cout << "Pretvornik casa hms - s" << endl;
  26. cout<< "Vpisi prvi cas: (h/m/s):";
  27. cin>>h>>m>>s;
  28. cout<<"Vpisi drugi cas: (h/m/s)";
  29. cin>>h1>>m1>>s1;
  30.  
  31. cout<<endl;
  32. cout<<"cas v sekundah= "<<hms_v_sec (h,m,s)<<endl;
  33. cout<<"cas v sekundah= "<<hms_v_sec1 (h1,m1,s1)<<endl;
  34.  
  35. if (hms_v_sec > hms_v_sec1)
  36. {
  37. skupno=hms_v_sec(h,m,s) - hms_v_sec1(h1,m1,s1);
  38. cout<<"razlika casov je: "<<skupno<<endl;
  39. }
  40. else
  41. skupno=hms_v_sec1(h1,m1,s1) - hms_v_sec(h,m,s);
  42. cout<<"Razlika casov je: "<<skupno<<endl;
  43.  
  44. sec_v_hms (skupno,h3,m3,s3);
  45. cout<<endl<<"ure: "<<h3<<", minute: "<<m3<<", sekunde: "<<s3<<endl;
  46.  
  47.  
  48.  
  49.  
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement