View Code of Problem 56

#include<stdio.h>
#include<math.h>
int main()
{
  int h1,h2,m1,m2,s1,s2,a,b,c;
  scanf("%d:%d:%d",&h1,&m1,&s1);
  scanf("%d:%d:%d",&h2,&m2,&s2);
  a=3600*h1+60*m1+s1;
  b=3600*h2+60*m2+s2;
  c=fabs(a-b);
  int h3,m3,s3;
  h3=c/3600;
  m3=c/60%60;
  s3=c%60;
  printf("%d:%d:%d",h3,m3,s3);
  return 0;
}

Double click to view unformatted code.


Back to problem 56