summaryrefslogblamecommitdiffstats
path: root/prog/aoc/23/1/1.c
blob: ce0f01fc4a1c09716567f2f7f157f6304c42fd25 (plain) (tree)




















                                                  
#include <stdio.h>
#include <stdlib.h>
int main (void) {
	int c = getchar();
	int prev = -1;
	int sum = 0;
	while (!ferror(stdin) && !feof(stdin)) {
		if (c == '\n') {
			sum += prev;
			prev = -1;
		}
		if (c <= '9' && c >= '0') {
			if (prev == -1)
				sum += 10*(c-'0');
			prev = c-'0';
		}
		c = getchar();

	}
	printf("%d\n", sum);
}