2023-12-01 13:22:00 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2023-12-04 20:24:17 +01:00
|
|
|
// Just part 1
|
2023-12-01 13:22:00 +01:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
|
|
|
|
char c;
|
|
|
|
int sum = 0;
|
|
|
|
int first = -1, last = -1;
|
|
|
|
while ((c = getchar()) != EOF) {
|
|
|
|
|
|
|
|
if (c == '\n') {
|
|
|
|
sum += last != -1 ? first*10 + last : first*10 + first;
|
|
|
|
first = -1;
|
|
|
|
last = -1;
|
|
|
|
} else {
|
|
|
|
if (c <= '9' && c >= '0') {
|
|
|
|
if (first == -1) {
|
|
|
|
first = c - '0';
|
|
|
|
} else {
|
|
|
|
last = c - '0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("%d\n", sum);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|