AoC2022/01.c

24 lines
322 B
C
Raw Normal View History

2022-12-03 01:26:39 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main () {
char cur[20];
int cur_sum = 0;
int max = 0;
while (fgets(cur,20,stdin) != NULL) {
if (strlen(cur) > 1) {
cur_sum += atoi(cur);
if (cur_sum > max) {
max = cur_sum;
}
} else {
cur_sum = 0;
}
}
printf("%d\n", max);
}