aboutsummaryrefslogtreecommitdiff
path: root/2023/01/1a.c
diff options
context:
space:
mode:
Diffstat (limited to '2023/01/1a.c')
-rw-r--r--2023/01/1a.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/2023/01/1a.c b/2023/01/1a.c
new file mode 100644
index 0000000..0983236
--- /dev/null
+++ b/2023/01/1a.c
@@ -0,0 +1,21 @@
1#include <stdio.h>
2
3#define N 10000
4
5int main() {
6 char *buf, line[N];
7 int first, last, sum;
8
9 sum = 0;
10 while ((buf = fgets(line, N, stdin)) != NULL) {
11 for (first = -1; *buf; buf++) {
12 if (*buf < '0' || *buf > '9')
13 continue;
14 first = first == -1 ? *buf - '0' : first;
15 last = *buf - '0';
16 }
17 sum += 10 * first + last;
18 }
19 printf("%d\n", sum);
20 return 0;
21}

Generated with cgit - Back to sebastiano.tronto.net