星光


私信TA

用户名:hnsnyswlqlyzztc

访问量:2292

签 名:

知行合一

等  级
排  名 730
经  验 3756
参赛次数 1
文章发表 54
年  龄 0
在职情况 学生
学  校 HCU
专  业

  自我简介:

解题思路:C里面有一个函数库<ctype.h>,里面包含了许多函数

注意事项:C语言定义完成后一定要赋值,如果是从键盘输入的话,可以直接定义,不用初始化,因为键盘上的值通过scanf()赋给了未知数

参考代码:

#include<stdio.h>

#include<ctype.h>

int main()

{

    int s;

    int leter_num=0,integer_num=0,blank_num=0,other_num=0;

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

    {

        if(isalpha(s))

        leter_num++;

        else if(isdigit(s))

        integer_num++;

        else if(s == ' ')

        blank_num++;

        else

        other_num++;

    }

    printf("%d %d %d %d",leter_num,integer_num,blank_num,other_num);

    return 0;

}


 

0.0分

0 人评分

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

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区