fork(4) download
  1. #include <stdio.h>
  2.  
  3. int main () {
  4. int h1, h2, m1, m2, t1, t2;
  5.  
  6. while (1) { //repete infinitamente
  7. scanf ("%i %i %i %i", &h1, &m1, &h2, &m2);
  8.  
  9. if (h1==0 && h2==0 && m1==0 && m2==0) {
  10. break; //para o while caso valores zero sejam fornecidos na entrada
  11. }
  12.  
  13. t1 = (h1 * 60) + m1;
  14. t2 = (h2 * 60) + m2;
  15.  
  16. if (t1 < t2) {
  17. printf ("%i\n", t2-t1);
  18. } else {
  19. printf ("%i\n", 1440+(t2-t1)); //24*60 = 1440
  20. }
  21. }
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 9432KB
stdin
1 5 3 5
23 59 0 34
21 33 21 10
0 0 0 0
stdout
120
35
1417