View Code of Problem 56

#include<stdio.h>
#include<math.h>
int main()
{
    int a,b,c,x,y,z,s1,s2,n,s,f,m;
    scanf("%d:%d:%d",&a,&b,&c);
    scanf("%d:%d:%d",&x,&y,&z);
    s1=a*3600+b*60+c;
    s2=x*3600+y*60+z;
    n=fabs(s1-s2);
    s=n/3600;
    f=(n-s*3600)/60;
    m=n-s*3600-f*60;
    printf("%d:%02d:%02d",s,f,m);
    return 0;
}

Double click to view unformatted code.


Back to problem 56