解题思路:
用ctype.h的字符判断函数
注意事项:

参考代码:

#include<stdio.h>

#include<ctype.h>


int main(void)

{

    int i_letter=0;

    int i_number=0;

    int i_space=0;

    int i_other=0;

    int c;


    printf("Please enter a string:");


    while((c=getchar())!='\n')

    {

        if(isalpha(c))

            i_letter++;

        else if(isdigit(c))

            i_number++;

        else if(isblank(c))

            i_space++;

        else

            i_other++;

    }


    printf("%d %d %d %d\n",i_letter,i_number,i_space,i_other);

    return 0;

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区