View Code of Problem 56

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
    int h1,h2,m1,m2,s1,s2,sum,h3,m3,s3;
    scanf("%d:%d:%d",&h1,&m1,&s1);
    scanf("%d:%d:%d",&h2,&m2,&s2);
    sum=abs(h1*3600+m1*60+s1-h2*3600-m2*60-s2);
    h3=sum/3600;
    m3=sum/60%60;
    s3=sum%60;
    printf("%d:%.02d:%.02d\n",h3,m3,s3);
    return 0;
}






Double click to view unformatted code.


Back to problem 56