View Code of Problem 56

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
using namespace std;
int main(){
	int h1,m1,s1;
	int h2,m2,s2;
	scanf("%d:%d:%d", &h1,&m1,&s1);
	scanf("%d:%d:%d", &h2,&m2,&s2);
    int  sm1 = h1*3600+m1*60+s1;
	int  sm2 = h2*3600+m2*60+s2;
	int sm3 = abs(sm1-sm2);
	int hour = sm3/3600;
	int minute = sm3%3600/60;
	int second = sm3%60;
	printf("%02d:%02d:%02d", hour, minute,second);
	return 0;
	
}

Double click to view unformatted code.


Back to problem 56