View Code of Problem 56

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

Double click to view unformatted code.


Back to problem 56