View Code of Problem 56

#include<stdio.h>
#include <string.h>
int main(){
	int h1,m1,s1;
	int h2,m2,s2;
	scanf("%d:%d:%d",&h1,&m1,&s1);
	scanf("%d:%d:%d",&h2,&m2,&s2);
	int t1=0,t2=0;
	int h3,m3,s3;
	int pass=0;
	t1=h1*3600+m1*60+s1;
	t2=h2*3600+m2*60+s2;
	if(t1<t2){
		pass=t2-t1;
	}
	else{
		pass=t1-t2;
	}
	h3=pass/3600;
	m3=(pass-h3*3600)/60;
	s3=(pass-h3*3600)%60;
	printf("%d:%02d:%02d",h3,m3,s3);
	printf("\n");
	return 0;
}

Double click to view unformatted code.


Back to problem 56