- 论坛徽章:
- 0
|
1 #include <stdio.h>
2 main()
3 {
4 int c, i, nwhite, nother;
5 int ndigit[10];
6 nwhite = nother = 0;
7 for (i = 0; i < 10; ++i)
8 ndigit[i] = 0;
9 while ((c = getchar()) != EOF)
10 if (c >= '0' && c <= '9')
11 ++ndigit[c-'0'];
12 else if (c == ' ' || c == '\n' || c == '\t')
13 ++nwhite;
14 else
15 ++nother;
16 printf("digits =");
17 for (i = 0; i < 10; ++i)
18 printf(" %d",ndigit[i]);
19 printf(", white space = %d, other = %d\n",nwhite,nother);
20 }
第11行
++ndigit[c-'0']
是怎么回事,数组自加运算结果是啥阿 |
|