第7周 C语言程序设计(新2版) 例题 1.6数组(无法编译)

来源:互联网 发布:苹果声场测试软件 编辑:程序博客网 时间:2024/04/30 09:49

问题及代码:

/*统计个数字、空白符及其他字符出现的次数*/#include<stdio.h>int main(){  int c,i,nother,nw;  int n[10];    nw=nother=0;     for(i=0;i<10;i++)         n[i]=0;             while((c=getchar())!=EOF)         if(c>='0'&&c<='9')  //判断c中的字符是否为数字            ++n[c-'0'];  //数字对应的数值         else if(c==' '||c=='\t'||c=='\n')            nw++;         else            nother++;        printf("数字的数组=");   for(i=0;i<10;++i)   printf("%d\n", n[i]);   printf("%d %d\n",nw,nother);}
无法运行

0 0
原创粉丝点击