Advertisement
nahidjamalli

Time for Nicholas

Apr 4th, 2020
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <cmath>
  4. using namespace std;
  5. char c1, c2, c3, c4;
  6. int main()
  7.  {
  8.     int h1,h2,h3,m1,m2,m3,s1,s2,s3;
  9.     cin>>h1>>c1>>m1>>c2>>s1>>h2>>c3>>m2>>c4>>s2;
  10.     if(m2>=m1 && s2>=s1)
  11.  {   h3=h2-h1;
  12.     m3=m2-m1;
  13.     s3=s2-s1;}
  14.     if(m2<m1 && s2>=s1)
  15.  {   h3=h2-h1-1;
  16.     m3=60-m1+m2;
  17.     s3=s2-s1;}
  18.     if(m2>=m1 && s2<s1)
  19.  {   h3=h2-h1;
  20.     m3=m2-m1-1;
  21.     s3=60-s1+s2;}
  22.     if(m2<m1 && s2<s1)
  23.  {   h3=h2-h1-1;
  24.     m3=60-m1+m2-1;
  25.     s3=60-s1+s2;}
  26.     if( h3 < 0 || m3 < 0 || s3 < 0 )
  27.     {
  28.      h3 = abs(h3);
  29.      m3 = abs(m3);
  30.      s3 = abs(s3);
  31.      }  
  32.      if( h3 > 12 )
  33.      h3 = 24 - h3;
  34.     if( m3 < 10 && s3 >= 10 && h3 >= 10 )
  35.     cout<<h3<<":0"<<m3<<":"<<s3<<endl;
  36.     if( s3 < 10 && h3 >= 10 && m3 >= 10 )
  37.     cout<<h3<<":"<<m3<<":0"<<s3<<endl;
  38.     if( h3 < 10 && s3 >= 10 && m3 >= 10 )
  39.     cout<<"0"<<h3<<":"<<m3<<":"<<s3<<endl;
  40.     if( m3 < 10 && s3 < 10 && h3 >= 10 )
  41.     cout<<h3<<":0"<<m3<<":0"<<s3<<endl;
  42.     if( m3 < 10 && h3 < 10 && s3 >= 10 )
  43.     cout<<"0"<<h3<<":0"<<m3<<":"<<s3<<endl;
  44.     if( s3 < 10 && h3 < 10 && m3 >= 10 )
  45.     cout<<"0"<<h3<<":"<<m3<<":0"<<s3<<endl;
  46.     if( s3 < 10 && h3 < 10 && m3 < 10 )
  47.     cout<<"0"<<h3<<":0"<<m3<<":0"<<s3<<endl;
  48.     if( s3 >= 10 && h3 >= 10 && m3 >= 10 )
  49.     cout<<h3<<":"<<m3<<":"<<s3<<endl;
  50.    
  51.     return EXIT_SUCCESS;
  52.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement