我在线等答案,求C语言好的人帮忙

来源:百度知道 编辑:UC知道 时间:2024/05/23 19:45:56
编程:输入一个含若干字符的字符串,分别统计出其中的字母和数字的个数.

#include<stdio.h>
main()
{char c;/*用来放输入的字符串*/
int word=0,data=0,others=0;/*word代表字母,data代表数字,others代表其它*/
printf("please input some characters\n");
while((c=getchar())!='\n')
{ if (c>='a'&&c<='z'||c>='A'&&c<='Z')
word++;
else if(c>='0'&&c<='9')
data++;
else
others++;
}
printf("word=%d data=%d others=%d\n",word,data,others);
}

你去编程论坛看看http://bbs.bc-cn.net/viewthread.php?tid=165222&page=1 肯定对你有点帮助的