第一个if(),括号中's'应该去掉'',写成s就好
还有else是紧跟着上一个if的,即你最后的else表示的是非数字字符。
while里面第一个if,s不用引号,因为s是字符变量,加引号是字符s
解答如下
#include<stdio.h>
#include<string.h>
int main()
{
char t[150];
gets(t);
int w=0,d=0,o=0,p=0;
for(int j=0; j<strlen(t); j++)
{
if((t[j]<='Z'&&t[j]>='A')||(t[j]<='z'&&t[j]>='a'))
{
w++;
}
else if(t[j]<='9'&&t[j]>='0')
{
d++;
}
else if(t[j]==' ')
{
p++;
}
else
{
o++;
}
}
printf("字母:%d\n数字:%d\n空格:%d\n其它:%d\n",w,d,p,o);
return 0;
}
空格