1a.c (368B)
1 #include <stdio.h> 2 3 #define N 10000 4 5 int 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') continue; 13 first = first == -1 ? *buf - '0' : first; 14 last = *buf - '0'; 15 } 16 sum += 10 * first + last; 17 } 18 printf("%d\n", sum); 19 return 0; 20 }