#include<stdio.h>
#include<ctype.h>
int main()
{
    int i=0;
    char str[]="abc 123 %&def";
    int other=0,blank=0,alpha=0,digital=0;
    while(str[i])
    {
        if(isalpha(str[i])) //判断是否是字母
        {
            alpha++;
        }
        else if(isblank(str[i]))//判断是否是空格
        {
            blank++;
        }
        else if(isdigit(str[i]))//判断是否是数字
        {
            digital++;
        }
        else
            other++;      //其它字符
            i++;
    }
    printf("字母是%d个\n",alpha);
    printf("数字是%d个\n",digital);
    printf("空格是%d个\n",blank);
    printf("其他是%d个\n",other);
    return 0;
}



相关文章:

  • 2021-07-01
  • 2022-12-23
  • 2022-12-23
  • 2021-04-29
  • 2022-01-02
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案