编写一个函数,由实参传来一个字符串,统计此字符串中字母,数字,空格,其他符号
https://blog.csdn.net/weixin_43788627/article/details/115800600
有帮助请采纳,谢谢
#include<stdio.h>
void funtion(char c[])
{
int y=0,s=0,q=0,t=0,i=0;
while(c[i]!='\0')
{
if((c[i]>='a'&&c[i]<='z')||(c[i]>='A'&&c[i]<='Z'))
{
y++;
}
else if(c[i]<='9'&&c[i]>='0')
{
t++;
}
else if(c[i]==' ')
{
s++;
}
else
{
q++;
}
i++;
}
printf("字母=%d,数字=%d,空格=%d,其他=%d\n",y,t,s,q);
}
int main()
{
char c[100];
gets(c);//用来接受从键盘输入的一个字符串(可带空格)
funtion(c);
return 0;
}