View Code of Problem 56

#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int main()
{
	int h1,m1,s1,h2,m2,s2,sum1,sum2,result;
	char c;
	cin>>h1>>c>>m1>>c>>s1;
	cin>>h2>>c>>m2>>c>>s2;
	
	sum1=h1*3600+m1*60+s1;
	sum2=h2*3600+m2*60+s2;
	
	result=(int)abs(sum1-sum2);
	
	cout<<result/3600<<":"<<setfill('0')<<setw(2)
	<<result/60%60<<":"<< setfill('0')<<setw(2)<<result%60;
 } 

Double click to view unformatted code.


Back to problem 56