Advertisement
noor017

Event Time

Jun 26th, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int d1, d2, h1, h2, m1, m2, s1, s2, stotal1, stotal2, stotal, dt, ht, mt, st;
  6.  
  7.     printf("Dia ");
  8.     scanf("%d", &d1);
  9.     scanf("%d : %d : %d", &h1, &m1, &s1);
  10.     printf("Dia ");
  11.     scanf("%d", &d2);
  12.     scanf("%d : %d : %d", &h2, &m2, &s2);
  13.  
  14.     stotal1 = d1*86400 + h1*3600 + m1*60 + s1;
  15.     stotal2 = d2*86400 + h2*3600 + m2*60 + s2;
  16.     stotal = stotal2 - stotal1;
  17.  
  18.     if(stotal>=60)
  19.     {
  20.         dt = stotal/86400;
  21.         ht = (stotal%86400)/3600;
  22.         mt = ((stotal%86400)%3600)/60;
  23.         st = ((stotal%86400)%3600)%60;
  24.  
  25.         printf("%d dia(s)\n", dt);
  26.         printf("%d horas(s)\n", ht);
  27.         printf("%d minutos(s)\n", mt);
  28.         printf("%d segundos(s)\n", st);
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement