diff options
Diffstat (limited to '8.c')
-rw-r--r-- | 8.c | 53 |
1 files changed, 53 insertions, 0 deletions
@@ -0,0 +1,53 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +static char *ReadLine(char *p, size_t size, FILE *fp) +{ + if ((p=fgets(p, size, fp))) + { + size_t l = strlen(p); + + while(l && p[l-1] == '\n') + { + p[--l] = 0; + } + } + + return p; +} + +int main(void) +{ + char buff[0x8000]; + char *signal[10] = {0}; + char *digit[4] = {0}; + int sum = 0; + int f = 0; + + while(ReadLine(buff, sizeof buff, stdin)) + { + for(f = 0; f < 10; f++) + { + signal[f] = strtok(f == 0 ? buff : NULL, " |"); + } + + for(f = 0; f < 4; f++) + { + size_t len; + + digit[f] = strtok(NULL, " |"); + + len = strlen(digit[f]); + + if (len == 2 || len == 4 || len == 3 || len == 7) + { + sum++; + } + } + } + + printf("sum = %d\n", sum); + + return 0; +} |