View Code of Problem 56

#include<stdio.h>
#include<math.h>
int main()
{
	int a,b,c,d,e,f;
	double time1,time2,sub;
	scanf("%d:%d:%d",&a,&b,&c);
	scanf("%d:%d:%d",&d,&e,&f);
	time1=c+60*b+3600*a;
	time2=f+60*e+3600*d;
	sub=fabs(time1-time2);
	int x,y,z;
	x=sub/3600;
	y=(sub-x*3600)/60;
	z=(int)sub%60;
	printf("%d:%02d:%02d",x,y,z);
}

Double click to view unformatted code.


Back to problem 56