View Code of Problem 56

# include<Stdio.h>
# include<math.h>
void addZero(int x){
	if(x<10){
		printf(":0%d",x);
	}
	else{
		printf(":%d",x);
	}
}
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;
	if(x1>x2){
		int temp=x1;
		x1=x2;
		x2=temp;
	} 
	int x=x2-x1;
	int h=x/3600;
	int m=(x%3600)/60;
	int s=(x%3600)%60;
	printf("%d",h);
	addZero(m);
	addZero(s);
	return 0;
}
/*
Main.c:1:19: fatal error: Stdio.h: No such file or directory
 # include<Stdio.h>
                   ^
compilation terminated.
*/

Double click to view unformatted code.


Back to problem 56