View Code of Problem 56

#include <stdio.h>
int main()
{
	int a,b,c;
	int d,e,f;
	int j,k,l;
	scanf("%d:%d:%d",&a,&b,&c);
	scanf("%d:%d:%d",&d,&e,&f);
	if(a>=d)
	{
		j = a - d;
	
		if(b>=e)
	{
		k = b - e;
	}
		if(b<e)
	{
		k = 60 - e + b;
		j = j - 1;
	}
		if(c>=f)
	{
		l = c - f;
	}
			if(c<f)
	{
		k = 60 - f + c;
		f = k - 1;
	}
	} 
			if(a<d)
	{
		j = d - a;
			if(e>=b)
	{
		k = e - b;
	}
		if(e<b)
	{
		k = 60 - b + e;
		j = j - 1;
	}
		if(f>=c)
	{
		l = f - c;
	}
			if(f<c)
	{
		k = 60 - c + f;
		f = k - 1;
	}
	}
	printf("%d:%d:%d",j,k,l); 
	return 0;
 } 

Double click to view unformatted code.


Back to problem 56