From 57d767cf4e4d5b83645bda2c4e398fdd76d059e1 Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Mon, 2 Jan 2017 20:37:59 +0700 Subject: Update others/easy20160714 --- others/easy20160714/18.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 others/easy20160714/18.c (limited to 'others/easy20160714/18.c') diff --git a/others/easy20160714/18.c b/others/easy20160714/18.c new file mode 100644 index 0000000..26f9e28 --- /dev/null +++ b/others/easy20160714/18.c @@ -0,0 +1,28 @@ +#include +#include + +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; +} -- cgit 1.4.1