View Code of Problem 56

#include <iostream>
#include <sstream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
#include <stack>
#include <map>
#include <set>
#include <queue>
using namespace std;
int change(int a,int b,int c)
{
    return a*3600+b*60+c;
}

int main()
    {
        #ifdef  ONLINE_JUDGE
        #else
        freopen("1.txt","r",stdin);
        #endif
        int a,b,c;
        scanf("%d:%d:%d",&a,&b,&c);
        int t1=change(a,b,c);
        scanf("%d:%d:%d",&a,&b,&c);
        int t2=change(a,b,c);
        int ans=abs(t1-t2);
        printf("%d:%02d:%02d",ans/3600,ans%3600/60,ans%60);

        return 0;
    }

Double click to view unformatted code.


Back to problem 56