#include <stdio.h> #include <math.h> int main() { char s1[9],s2[9]; gets(s1);gets(s2); int h1=s1[0]*10+s1[1],h2=s2[0]*10+s2[1]; int m1=s1[3]*10+s1[4],m2=s2[3]*10+s2[4]; int ss1=s1[6]*10+s1[7],ss2=s2[6]*10+s2[7]; int t1=h1*3600+m1*60+ss1,t2=h2*3600+m2*60+ss2; int t=fabs(t2-t1); int h,m,s; h=t/3600; m=(t-h*3600)/60; s=(t-3600*h-60*m); printf("%d:%02d:%02d",h,m,s); } |
Double click to view unformatted code.