View Code of Problem 56

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

Double click to view unformatted code.


Back to problem 56