View Code of Problem 56

#include<stdio.h>
main(){
	int h1,m1,s1;
	int h2,m2,s2;
	int h,m,s,x,y,z;
	scanf("%d:%d:%d",&h1,&m1,&s1);
	scanf("%d:%d:%d",&h2,&m2,&s2);
	x=s1+m1*60+h1*3600;
	y=s2+m2*60+h2*3600;
	if(x>=y)
		z=x-y;
	else
		z=y-x;
	h=z/3600;
	m=(z-h*3600)/60;
	s=z-h*3600-m*60;
	printf("%d:%02d:%2d",h,m,s);
}

Double click to view unformatted code.


Back to problem 56