blob: 8949db51f91b8ede29bb05044ad3ea45e2a6e1ce (
plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#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[1024];
unsigned long long num[9] = {0};
unsigned long long num_count = 0;
char *p = NULL;
int f = 0;
int cycle = 0;
ReadLine(buff, sizeof buff, stdin);
p = strtok(buff, ",");
while(p)
{
num[atoi(p)]++;
p = strtok(NULL, ",");
}
for(cycle = 0; cycle < 256; cycle++)
{
unsigned long long zero = 0;
zero = num[0];
for(f=0; f < 8; f++)
{
num[f] = num[f+1];
}
num[6] += zero;
num[8] = zero;
}
for(f = 0; f < 9; f++)
{
num_count += num[f];
}
printf("num_count=%llu\n", num_count);
return 0;
}
|