View Code of Problem 56

#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
	int a,b,c,d,f,g;
	int  s;
	scanf("%d:%d:%d",&a,&b,&c);
	scanf("%d:%d:%d",&d,&f,&g);
	s=(a*60+b)*60+c-((d*60+f)*60+g);
	if(s<0)s=-s;
	int x=s/60/60;
	int y=(s-x*60*60)/60;
	int z=(s-x*60*60)%60; 
	printf("%d:%02d:%02d",x,y,z);
	
} 

Double click to view unformatted code.


Back to problem 56