View Code of Problem 56

#include "stdio.h"
#include "math.h"
#include "string.h"

void main()
{
	int i,j,k;
	int a,b,c;
	int x,y,z;
	int cha1,cha2;
	int sum;
	scanf("%d:%d:%d",&a,&b,&c);
	scanf("%d:%d:%d",&x,&y,&z);
	//printf("%d %d %d %d %d %d ",a,b,c,x,y,z);
	cha1=a*3600+b*60+c;
	cha2=x*3600+y*60+z;
	if(cha1>cha2)
		sum=cha1-cha2;
	else
		sum=cha2-cha1;
	//printf("%d",sum);
	x=sum/3600;
	sum=sum%3600;
	y=sum/60;
	sum=sum%60;
	z=sum;
	printf("%02d:%02d:%02d",x,y,z);
}

Double click to view unformatted code.


Back to problem 56