输入15个字符,统计并输出空格或回车、数字字符和其他字符的个数。要求使用switch语句编写。请注意,输入15个字符后,需回车表示输入结束,这最后一个回车表示输入结束,不统计在内。

输入15个字符,统计并输出空格或回车、数字字符和其他字符的个数。要求使用switch语句编写。请注意,输入15个字符后,需回车表示输入结束,这最后一个回车表示输入结束,不统计在内。

include <stdio.h>`

int main()
{
int blank, digit, i, other;
char ch;

blank = digit = other = 0; 
for(i = 1; i <= 15; i++){ 
    ch = getchar();  
    switch 

{

    }     
}
printf("blank = %d, digit = %d, other = %d\n", blank, digit, other);

return 0;

}


#include<stdio.h>
int main(void)
{
    int yinwen,shuzi,koge,other;
    char ch;
    int i;
    yinwen=shuzi=koge=other=0;
    printf("Enter 15 characters:");
    for(i=1;i<=15;i++){
        ch=getchar( );
            if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
                yinwen++;
            else if(ch>='0'&&ch<='9')
                shuzi++;
            else if(ch>=' '&&ch<='\n')
                koge++;
            else
                other++;
    }
    printf("yinwen=%d,shuzi=%d,koge=%d,other=%d\n",yinwen,shuzi,koge,other);

    return 0;

}
switch(ch){
    case ' ':
    case '\n':blank++;break;
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':digit++;break;
    default:other++;break;
 
}

img