菜鸟求助阿
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']
是怎么回事,数组自加运算结果是啥阿
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
明白了,献丑献丑{:3_186:}
回复 2# a55569769
不是数组自加,是数组的那个元素。下标运算符[]的优先级比++高很多。
权且数字名是个常量,不能对它做算术操作。
回复 3# nketc
恩,直到拉,谢谢阿