View Code of Problem 56

#include<stdio.h>
#include<math.h>
int main()
{
	int h1,m1,s1;
	int h2,m2,s2;
	scanf("%d:%d:%d",&h1,&m1,&s1);
	scanf("%d:%d:%d",&h2,&m2,&s2);
	double time1,time2,sub;
	time1=3600*h1+60*m1+s1;
	time2=3600*h2+60*m2+s2;
	sub=fabs(time1-time2);
	int x,y,z;
	x=sub/3600;
	y=(sub-3600*x)/60;
	z=sub-3600*x-60*y;
	printf("%d:%02d:%02d",x,y,z);
	return 0;
}

Double click to view unformatted code.


Back to problem 56