View Code of Problem 56

#include<stdio.h>
int main(){
  int h1,m1,s1;
  int h2,m2,s2;
  int x,y,z,h,m,s;
  scanf("%d:%d:%d",&h1,&m1,&s1);
  scanf("%d:%d:%d",&h2,&m2,&s2);
  x=h1*3600+m1*60+s1;
  y=h2*3600+m2*60+s2;
  if(x>=y)
  {
  z=x-y;
  }
  else{
   z=y-x; 
  }
  h=z/3600;
  m=z%3600/60;
  s=z%3600%60;
  printf("%d:%d:%d",h,m,s);
  return 0;
}

Double click to view unformatted code.


Back to problem 56