#include
#include
int main()
{
int c, i, numWhite = 0, numOther = 0;
//int ndigit[10] = {0};
int numDigit = 0;
while ((c = getchar()) != EOF){
if (c >= '0' && c <= '9')
++numDigit;//++ndigit[c-'0'];
else if (c == ' ' || c == '\n' || c =='\t')
++numWhite;
else
++numOther;
}
//printf("digist =");
//for (i = 0;i < 10;++i)
printf("numDigit = %d, ", numDigit);//printf(" %d",ndigit[i]);
printf("white space = %d, other = %d\n", numWhite, numOther);
Sleep(3000);
return 0;
}
按照你的意思,在你的源代码上改了下,可以看下,有疑问咱们再讨论。
就你的题目统计各字符个数而言,那么你的程序中,while模块的范围应该到else,缺‘{}’,给while这个模块加上‘{}’
别逗了。。。。。。。。。。