输入一行字符,分别统计出其中的英文字母、空格、数字和其他字符的个数。
#include<stdio.h>
int main()
{
int i=0,temp1=0,temp2=0,temp3=0,temp4=0;
char str[100];
gets(str);
while(str[i]!='\0')
{
if(str[i]>='A'&&str[i]<='z')
temp1++;
else if(str[i]>='0'&&str[i]<='9')
temp2++;
else if(str[i]==' ')
temp3++;
else
temp4++;
i++;
}
printf("英文字母数为%d,数字为%d,空格为%d,其他字符为%d\n",temp1,temp2,temp3,temp4);
return 0;
}
如果有帮助请采纳一下谢谢