#include<stdio.h> #include<math.h> int main(){ int h,hh,m,mm,s,ss; int H,M,S; scanf("%d:%d:%d",&h,&m,&s); scanf("%d:%d:%d",&hh,&mm,&ss); int second1=h*60*60+m*60+s; int second2=hh*60*60+mm*60+ss; //int space=abs(second2-second1); int space; if(second1>=second2){ space=second1-second2; } else space=second2-second1; S=space%60; M=space/60%60; H=space/3600%60; printf("%d:%02d:%02d",H,M,S); } |
Double click to view unformatted code.