View Code of Problem 56

# include<stdio.h>
# include<math.h>
int main(){
	int xh,xm,xs,yh,ym,ys;
	scanf("%d:%d:%d",&xh,&xm,&xs);
	scanf("%d:%d:%d",&yh,&ym,&ys);
	int x1=xh*3600+xm*60+xs;
	int x2=yh*3600+ym*60+ys; 
	int x=fabs(x2-x1);
	int h=x/3600;
	int m=(x%3600)/60;
	int s=(x%3600)%60;
	printf("%d:%02d:%02d",h,m,s);
	return 0;
}

Double click to view unformatted code.


Back to problem 56