2、用scanf("%c",ch)循环读入,每读入一个即判断后加入a或b或c或d,如果读到ch==10(回车),则执行3
3、输出a、b、c、d
#include
#include
main()
{
int a=0,b=0,c=0,d=0;
char ch;
system("cls");
printf("Input a string with enter end:");
scanf("%c",&ch);
while (ch!=10)
{
if ((ch>='A' && ch<='Z') || (ch>='a') && (ch<='z'))
a++;
else if (ch==' ')
b++;
else if (ch>='0' && ch<='9')
c++;
else
d++;
scanf("%c",&ch);
}
printf("\nA-Z,a-z:%d,blank:%d,number:%d,others:%d\n\n",a,b,c,d);
system("pause");
}