题解 | #字母统计#

字母统计

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

#include <stdio.h>
#include <string.h>
int main(){
    char arr[100];  //输入的最大长度
    scanf("%s", arr);
    int len = strlen(arr);
    int num;
    int count[91] = {0};    //只有65-90有用
    for (int i = 65; i <= 90; ++i) {    //A-Z对应为65-90
        for (int j = 0; j < len; ++j) {
            num = arr[j];   //把字符转化为对应的ASCII码
            if (num == i){
                count[i]++;
            }
        }
    }
    for (int i = 65; i <= 90; ++i) {
        printf("%c:%d\n", i, count[i]);
    }
    return 0;
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-03 16:22
点赞 评论 收藏
分享
06-14 19:09
门头沟学院 Java
darius_:给制造业搞的,什么物料管理生产管理,设备管理点检,最最关键的就是一堆报表看板。个人觉得没啥技术含量都是些基本的crud,但是业务很繁琐那种
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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