用C语言编写一个程序:从键盘输入若干个字符,分别统计其中字母符号(区别大。小),数字字符和其他字符的
#include
#include
void main()
{
int i=0,n=0,m=0,j=0,k=0;
char str[100];
printf("please input one string。
\n");
scanf("%s",str);
printf("\n");
while(str[i]!='\0')
{
if(str[i]>='a'&&str[i]='A'&&str[i]='0'&&str[i]<='9')j++;
else k++;
i++;
}
printf("小写字母:%d\n",n);
printf("大写字母:%d\n",m);
printf("数字:%d\n",j);
printf("其他:%d\n",k);
}。
楼上的scanf("%s",str);函数是以空格或回车为中止符的,建议换个