View Code of Problem 56

#include <stdio.h>
int main(){
  int a[3];
  int b[3];
  long t1,t2;
  scanf("%d:%d:%d",a,a+1,a+2);
  scanf("%d:%d:%d",b,b+1,b+2);
  t1 = a[0]*60*60+a[1]*60+a[2];
  t2 = b[0]*60*60+b[1]*60+b[2];
  t1= t2-t1;
  printf("%s",t1>0?"":"-");
  t1=t1>0?t1:-1*t1;
  printf("%d:",t1/3600);
  t1 = t1%3600;
  printf("%02d:",t1/60);
  printf("%02d\n",t1%60);
  
}

Double click to view unformatted code.


Back to problem 56