about summary refs log tree commit diff
path: root/others/easy20160714/18.c
blob: 26f9e28fff44f65ecb4903a3630463eb8bea7537 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <ctype.h>
#include <stdio.h>

int main()
{
	FILE *f = fopen("INP.TXT", "r");
	char c, prevc = 100;
	unsigned long long x = 0, y = 0;

	while ((c = fgetc(f)) != EOF) {
		if (isdigit(prevc) && !isdigit(c)) {
			y += x;
			x = 0;
		} else if (isdigit(c)) {
			x = x * 10 + c - 48;
		}

		prevc = c;
	}

	fclose(f);

	f = fopen("OUT.TXT", "w");
	fprintf(f, "%lld\n", y);
	fclose(f);

	return 0;
}