aoc23/01/main1.c

21 lines
404 B
C

#include <stdio.h>
int main(void) {
int c, num1, num2, sum;
num1 = 0;
num2 = 0;
sum = 0;
while ((c = fgetc(stdin)) != EOF) {
if (c >= '0' && c <= '9') {
num1 = num1 == 0 ? c - '0' : num1;
num2 = c - '0';
} else if (c == '\n') {
sum += num1*10 + num2;
num1 = 0;
}
}
printf("%d\n", sum);
return 0;
}