Advertisement
VitorMDias

uri1061

Aug 31st, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.15 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5.  
  6. int main()
  7. {
  8.     int  dia1 [20], dia2 , w , x , y , z , d1 , d2 , h1 , h2 , m1 , m2 , s1 , s2;
  9.     scanf("%s" , &dia1);
  10.     scanf("%d" , &d1);
  11.     scanf("%d" , &h1);
  12.     scanf(" : ");
  13.     scanf("%d" , &m1);
  14.     scanf(" : ");
  15.     scanf("%d" , &s1);
  16.      
  17.     scanf("%s" , &dia2);
  18.     scanf("%d" , &d2);
  19.     scanf("%d" , &h2);
  20.     scanf(" : ");
  21.     scanf("%d" , &m2);
  22.     scanf(" : ");
  23.     scanf("%d" , &s2);
  24.     w = d2 - d1;
  25.     x = h2 - h1;
  26.     y = m2 - m1;
  27.     z = s2 - s1;
  28.     if (h1 > h2)
  29.     {
  30.         x = (24 + h2) - h1;
  31.         w = w - 1;
  32.     }
  33.     if (m1 > m2)
  34.     {
  35.         y = (60 + m2) - m1;
  36.         x = x - 1;
  37.     }
  38.     if (s1 > s2)
  39.     {
  40.         z = (60 + s2) - s1;
  41.         y = y - 1; 
  42.     }
  43.      
  44.     printf("%d dia(s)\n" , w);
  45.     printf("%d hora(s)\n" , x);
  46.     printf("%d minuto(s)\n" , y);
  47.     printf("%d segundo(s)\n" , z);
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement