| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 470 人关注过本帖
标题:数组统计数字,空白符,其他字符的代码问题
取消只看楼主 加入收藏
bingnongkoo
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-1-25
结帖率:0
收藏
已结贴  问题点数:20 回复次数:0 
数组统计数字,空白符,其他字符的代码问题
刚开始学,自己努力后无果来询问,请问有什么问题,if后不加{},谢谢
#include<stdio.h>
main()
{
int c,i,nwhite,nother;
int ndigit[10];
nwhite=nother=0;
for(i=0;i<10;++i)
ndigit[i]=0;
while((c=getchar())!=EOF)
if(c>='0'&&c<='9')
++ndigit[c-'0'];
else if(c==" "||c=="\n"||c=="\t")
++nwhite;
else
++nother;
printf("digits=");
for(i=0;i<10;++i)
printf("%d",ndigit[i]);
printf(",white space=%d,other=%d",nwhite,nother);
}
搜索更多相关主题的帖子: 统计 
2014-01-25 20:27
快速回复:数组统计数字,空白符,其他字符的代码问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011263 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved