题解 | #计算某字符出现次数#

计算某字符出现次数

https://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1

没找到c语言正确代码,出一个:
#include <stdio.h>
#include <ctype.h>

int main(){
    char s[1010];
    char c;
    fgets(s, 1010, stdin);
    c = getchar();
    if(isupper(c)) c = tolower(c);
    int count = 0;
    for(int i = 0; s[i] != '\0';i++){
        if(isalpha(s[i])) s[i] = tolower(s[i]);
        if(c == s[i]) count++;
    }
    printf("%d",count);
    return 0;
}

#C笔试面试##字节跳动深圳租房##游戏开发##京东招聘##咪咕互娱#
全部评论

相关推荐

不愿透露姓名的神秘牛友
昨天 11:21
被夸真的超级开心,好可爱的姐姐
码农索隆:老色批们不用脑补了,我把金智妮的图找来了查看图片
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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