Skip to content

Commit

Permalink
Solve Alarm Clock in c
Browse files Browse the repository at this point in the history
  • Loading branch information
deniscostadsc committed Aug 22, 2024
1 parent 448d3ba commit e96a9e9
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions solutions/beecrowd/1103/1103.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <stdint.h>
#include <stdio.h>

int main() {
int32_t hi, hf, mi, mf, m;

while (1) {
scanf("%d %d %d %d", &hi, &mi, &hf, &mf);

if (hi == 0 && hf == 0 && mi == 0 && mf == 0) {
break;
}

if (hi <= hf) {
m = (hf - hi) * 60;
} else {
m = (24 - (hi - hf)) * 60;
}

if (mi <= mf) {
m += mf - mi;
} else {
m += 60 - 60 - mi + mf;
}

if (hi == hf && mi > mf) {
m = 23 * 60 + (60 - mi + mf);
}

printf("%d\n", m);
}

return 0;
}

0 comments on commit e96a9e9

Please sign in to comment.