Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <cmath>
- using namespace std;
- char c1, c2, c3, c4;
- int main()
- {
- int h1,h2,h3,m1,m2,m3,s1,s2,s3;
- cin>>h1>>c1>>m1>>c2>>s1>>h2>>c3>>m2>>c4>>s2;
- if(m2>=m1 && s2>=s1)
- { h3=h2-h1;
- m3=m2-m1;
- s3=s2-s1;}
- if(m2<m1 && s2>=s1)
- { h3=h2-h1-1;
- m3=60-m1+m2;
- s3=s2-s1;}
- if(m2>=m1 && s2<s1)
- { h3=h2-h1;
- m3=m2-m1-1;
- s3=60-s1+s2;}
- if(m2<m1 && s2<s1)
- { h3=h2-h1-1;
- m3=60-m1+m2-1;
- s3=60-s1+s2;}
- if( h3 < 0 || m3 < 0 || s3 < 0 )
- {
- h3 = abs(h3);
- m3 = abs(m3);
- s3 = abs(s3);
- }
- if( h3 > 12 )
- h3 = 24 - h3;
- if( m3 < 10 && s3 >= 10 && h3 >= 10 )
- cout<<h3<<":0"<<m3<<":"<<s3<<endl;
- if( s3 < 10 && h3 >= 10 && m3 >= 10 )
- cout<<h3<<":"<<m3<<":0"<<s3<<endl;
- if( h3 < 10 && s3 >= 10 && m3 >= 10 )
- cout<<"0"<<h3<<":"<<m3<<":"<<s3<<endl;
- if( m3 < 10 && s3 < 10 && h3 >= 10 )
- cout<<h3<<":0"<<m3<<":0"<<s3<<endl;
- if( m3 < 10 && h3 < 10 && s3 >= 10 )
- cout<<"0"<<h3<<":0"<<m3<<":"<<s3<<endl;
- if( s3 < 10 && h3 < 10 && m3 >= 10 )
- cout<<"0"<<h3<<":"<<m3<<":0"<<s3<<endl;
- if( s3 < 10 && h3 < 10 && m3 < 10 )
- cout<<"0"<<h3<<":0"<<m3<<":0"<<s3<<endl;
- if( s3 >= 10 && h3 >= 10 && m3 >= 10 )
- cout<<h3<<":"<<m3<<":"<<s3<<endl;
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement