Skip to content

Commit

Permalink
Solve Game Time with Minutes in c
Browse files Browse the repository at this point in the history
  • Loading branch information
deniscostadsc committed Sep 19, 2024
1 parent aecba0b commit 0cf5dd8
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions solutions/beecrowd/1047/1047.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <stdint.h>
#include <stdio.h>

int main() {
int16_t hi, mi, hf, mf, mr, hr;

while (scanf("%d %d %d %d", &hi, &mi, &hf, &mf) != EOF) {
hr = hf - hi;
if (hr < 0) {
hr += 24;
}

mr = mf - mi;
if (mf - mi < 0) {
mr += 60;
hr--;
}

if (hr < 0) {
hr += 24;
}

if (hf == hi && mf == mi) {
printf("O JOGO DUROU 24 HORA(S) E 0 MINUTO(S)\n");
} else {
printf("O JOGO DUROU %d HORA(S) E %d MINUTO(S)\n", hr, mr);
}
}

return 0;
}

0 comments on commit 0cf5dd8

Please sign in to comment.