View Code of Problem 56

#include<stdio.h>
#include<math.h>
int main()
{
	int a1,b1,c1,a2,b2,c2;
		int h,m,s;
	scanf("%d:%d:%d",&a1,&b1,&c1);
	scanf("%d:%d:%d",&a2,&b2,&c2);
	int sum1=0,sum2=0;
	sum1=a1*60*60+b1*60+c1;
	sum2=a2*60*60+b2*60+c2;
	if(sum2<sum1)
	{
		int k=sum1;
		sum1=sum2;
		sum2=k;
	}
	h=(sum2-sum1)/3600;
	m=(sum2-sum1-h*3600)/60;
	s=sum2-sum1-h*3600-m*60;
	printf("%d:%02d:%02d",h,m,s);
}   

Double click to view unformatted code.


Back to problem 56