#include<string.h>
#include<stdio.h>
main()
{char c;
int w=0,x=0,y=0,z=0;
while((c=getchar())!='\n')
{if((c>='a'&& c<='z')||(c>='A' && c<='z'))
w++;
else if (c==' ')
x++;
else if (c>='0' && c<='9')
y++;
else
z++;
}
printf("w=%d,x=%d,y=%d,z=%d",w,x,y,z);
}
这个程序运行是对的,但我有点看不明白
题目是输入一行字符,程序中c=getchar()是单个字符输入呀!应该改成c=gets()
请高手指点。