用数组的方法来实现程序 程序功能是:从键盘输入不超过50个字符 统计计算器中英

统计计算其中英文字符空格字符数字字符以及其他字符的个数,并输出计算结果

#include <stdio.h>
void main()
{
char c,str[51];
int i=0,letters=0,space=0,digit=0,others=0;
printf("请输入不超过50个字符\n");
gets(str);
while((c=str[i++])!=0)
{
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
letters++;
else if(c==' ')
space++;
else if(c>='0'&&c<='9')
digit++;
else
others++;
}
printf("英文字符:%d 空格:%d 数字:%d 其他:%d\n",letters,space,digit,others);
}
温馨提示:答案为网友推荐,仅供参考