View Code of Problem 56

#include<stdio.h>
#include<math.h>
int main(){
	int H1,M1,S1,H2,M2,S2,T1,T2,tep,H3,M3,S3,C;
	scanf("%d:%d:%d %d:%d:%d",&H1,&M1,&S1,&H2,&M2,&S2);
	T1=H1*3600+M1*60+S1;
	T2=H2*3600+M2*60+S2;
	if(T1>T2){
		tep=T1;
		T1=T2;
		T2=tep;
	}
	C=T2-T1;
	H3=C/3600;
	M3=(C-H3*3600)/60;
	S3=C-H3*3600-M3*60;
	printf("%d:%02d:%02d\n",H3,M3,S3);
	return 0;
} 

Double click to view unformatted code.


Back to problem 56