# URI Online Judge Solution 1047-Game Time With Minutes | URI 1047 Solution in C,C++,Python

## URI Online Judge Solution  1047-Game Time With Minutes | URI 1047 Solution in C,C++,Python

Read the start time and end time of a game, in hours and minutes (initial hour, initial minute, final hour, final minute). Then print the duration of the game, knowing that the game can begin in a day and finish in another day,

Obs.: With a maximum game time of 24 hours and the minimum game time of 1 minute.

## Input

Four integer numbers representing the start and end time of the game.

## Output

Print the duration of the game in hours and minutes, in this format: “O JOGO DUROU XXX HORA(S) E YYY MINUTO(S)” . Which means: the game lasted XXX hour(s) and YYY minutes.

 Input Sample Output Sample 7 8 9 10 O JOGO DUROU 2 HORA(S) E 2 MINUTO(S)
 7 7 7 7 O JOGO DUROU 24 HORA(S) E 0 MINUTO(S)
 7 10 8 9 O JOGO DUROU 0 HORA(S) E 59 MINUTO(S)

### URI Online Judge Solution  1047-Game Time With Minutes | URI 1047 Solution in C,C++,Python :

Demonstration:

### Example of how to calculate total hours worked:

Here we are going to explain how to manually calculate hours worked.  To do this, you will need a start and end time. The goal is to determine an entire duration worked using the recorded hours.  For example, starting @8:30 am and ending @3:45 pm would result in 7 hours and 15 minutes worked.

Here's how to determine hours worked:

1. Convert all times to 24 hour clock (military time):
1. Convert 8:45 am to 08:45 hours.
2. Convert 3:45 pm to 15:45 hours.
2. Next, Subtract the start time from the end time.
3. Now you have the actual hours worked for the day.
4. Finally to determined total time duration.
N.B: Don't copy paste the code as same. Just try to understand it and try yourself. It would be better for you.

URI Problem 1047 Solution in C :

 URI Online Judge 1047 Solve  in C :
```#include <stdio.h>
int main()
{
int a, b, c, d;
int dif;
scanf("%d %d %d %d", &a, &c, &b, &d);
dif = ((b*60)+d) - ((a*60)+c);
if(dif<=0) dif += 24*60;
printf("O JOGO DUROU %d HORA(S) E %d MINUTO(S)\n", dif/60, dif%60);
return 0;
}
```