Advertisement
Josif_tepe

Untitled

Dec 10th, 2021
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int poceten_cas, pocetna_minuta;
  8.     cin >> poceten_cas >> pocetna_minuta;
  9.     int kraen_cas, krajna_minuta;
  10.     cin >> kraen_cas >> krajna_minuta;
  11.     int mp = (poceten_cas * 60) + pocetna_minuta;
  12.     int mk = (kraen_cas * 60) + krajna_minuta;
  13.     if (poceten_cas > kraen_cas)
  14.     {
  15.         mk += 1440;
  16.     }
  17.     else if (poceten_cas == kraen_cas and pocetna_minuta > krajna_minuta)
  18.     {
  19.         mk += 1440;
  20.     }
  21.     int vremetraenje = mk - mp;
  22.     int ac = vremetraenje / 60;
  23.     int am = vremetraenje % 60;
  24.     if (ac < 10)
  25.     {
  26.         cout << "0";
  27.     }
  28.     cout << ac << ":";
  29.     if (am < 10)
  30.     {
  31.         cout << "0";
  32.     }
  33.     cout << am << endl;
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement