//alphabet 英文字母 ,blank 空格,数字 digit
#include <stdio.h>
int main()
{
    char c;
    int alphabet=0,blank=0,digit=0,other=0;
    printf("请输入一行字符:\n");
    c=getchar();
    while(c!='\n')
    {
        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\n空格个数:%d\n数字个数:%d\n其余符号个数:%d\n",alphabet,blank,digit,other);
    return 0;
 }

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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-04
  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
相关资源
相似解决方案