您的位置:首页 > 其它

作业3(3)输入 15 个字符,统计其中英文字母、空格或回车、数字字符和其他字符的个数

2013-10-17 20:34 309 查看
#include<stdio.h>
int main(void)
{
int yinwen,shuzi,koge,other;
char ch;
int i;
yinwen=shuzi=koge=other=0;
printf("Enter 15 characters:");
for(i=1;i<=15;i++){
ch=getchar( );
if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
yinwen++;
else if(ch>='0'&&ch<='9')
shuzi++;
else if(ch>=' '&&ch<='\n')
koge++;
else
other++;
}
printf("yinwen=%d,shuzi=%d,koge=%d,other=%d\n",yinwen,shuzi,koge,other);

return 0;

}




内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐