View Code of Problem 56

#include <stdio.h>
#include <math.h>
#include <string.h>
int main()
{
	int a,b,c,d,e,f;
	scanf("%d:%d:%d",&a,&b,&c);
	scanf("%d:%d:%d",&d,&e,&f);
	int m,n,h;
	m=3600*a+60*b+c;
	n=3600*d+60*e+f;
	if(m-n>0){
		h=m-n;
	}
	else
	{
		h=n-m;
	}
	a=h/3600;
	b=(h-3600*a)/60;
	c=h%60;
	printf("%d:%02d:%02d\n",a,b,c);
	return 0;
}

Double click to view unformatted code.


Back to problem 56