输入一行字符,分别统计出其中英文字母、空格、数字和其他字符

//alphabet 英文字母 ,blank 空格,数字 digit
#include <stdio.h>
int main()
{
    char c;
    int alphabet=0,blank=0,digit=0,other=0;
    printf("请输入一行字符: ");
    c=getchar();
    while(c!=' ')
    {
        if(c>='A'&&c<='Z'||c>='a'&&c<='z')
        alphabet++;
        else if(c==' ')
        blank++;
        else if(c>='0'&&c<='9')
        digit++;
        else
        other++;
        c=getchar();
    }
    printf("字母个数:%d 空格个数:%d 数字个数:%d 其余符号个数:%d ",alphabet,blank,digit,other);
    return 0;
 }

原文地址:https://www.cnblogs.com/LiQingXin/p/12844785.html