View Code of Problem 56

#include<stdio.h>
#include<math.h>
int main(){
	int a,b,c,x,y,z;
	int t1,t2,m,n,i,j;
    scanf("%d:%d:%d",&a,&b,&c);
    scanf("%d:%d:%d",&x,&y,&z);
	t1=a*3600+b*60+c;
    t2=x*3600+y*60+z;
    m=fabs(t1-t2);
    n=m/3600;
    i=(m-n*3600)/60;
    j=m-n*3600-i*60;
    printf("%d:%02d:%02d",n,i,j);
	return 0;
}

Double click to view unformatted code.


Back to problem 56