Advertisement
PROFESSOR_AIH

Game time with minutes

Mar 26th, 2022
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int srth,endh,srtm,endm,hour,mnt;
  5.     scanf("%d %d %d %d",&srth,&srtm,&endh,&endm);
  6.     if(endm<srtm)
  7.     {
  8.         endm=(60+endm);
  9.         endh=endh-1;
  10.         mnt=endm-srtm;
  11.         if(srth>endh)
  12.         {
  13.             hour=((endh+24)-srth);
  14.         }
  15.         else
  16.         {
  17.             hour=(endh-srth);
  18.         }
  19.         printf("O JOGO DUROU %d HORA(S) E %d MINUTO(S)\n",hour,mnt);
  20.     }
  21.     else if(endm>srtm)
  22.     {
  23.         mnt=endm-srtm;
  24.         if(srth>endh)
  25.         {
  26.             hour=(endh+24)-srth;
  27.         }
  28.         else
  29.         {
  30.             hour=endh-srth;
  31.         }
  32.         printf("O JOGO DUROU %d HORA(S) E %d MINUTO(S)\n",hour,mnt);
  33.     }
  34.     else if(srtm==endm && srth==endh)
  35.     {
  36.         printf("O JOGO DUROU 24 HORA(S) E 0 MINUTO(S)\n");
  37.     }
  38.  
  39.     return 0;
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement