题解 | #字符统计#

字符统计

https://ac.nowcoder.com/acm/problem/22202

C标准中有一个一个头文件<ctype.h>,这里面定义了一批C语言字符处理函数,用于测试字符是否属于特定的字符类别
#include<stdio.h>
#include<ctype.h>
int main()
{
    int letter=0,number=0,others=0,c;
    while((c=getchar())!='?')
    {
        if(isalpha(c))//判断是否为字母
        letter++;
        else if(isdigit(c)) //判断是都为数字
        number++;
        else                //其他
        others++;
    }
    printf("Letters=%d\nDigits=%d\nOthers=%d\n",letter,number,others);
}

全部评论
能帮忙看一下吗?通过率50%,找不到问题在哪 #include<stdio.h> #include<ctype.h> int main() { char str[100]; int i=0,Letters=0,Digits=0,Others=0; scanf("%s",str); while(str[i]!='?') { if(isalpha(str[i])) { Letters++; } else if(isdigit(str[i])) { Digits++; } else Others++; i++; } printf("Letters=%d\nDigits=%d\nOthers=%d\n",Letters,Digits,Others); }</ctype.h></stdio.h>
2 回复 分享
发布于 2023-12-02 11:19 河北

相关推荐

2025-12-28 22:19
门头沟学院 Java
不敢追165女神:简历写得毫无特点,你说你要是大二或者大三找寒假实习到暑期实习这段时间,你的简历还能约到面试。但是你是研究生哥,面试官不会因为你是研究生而降低要求,反而会觉得你是研究生才学了这么一点?为什么我不找个同阶段的本科生?
简历中的项目经历要怎么写
点赞 评论 收藏
分享
点赞 评论 收藏
分享
01-16 21:34
武汉大学 Java
点赞 评论 收藏
分享
评论
7
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务