题解 | #字母统计#

字母统计

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

#include<cstdio>
#include<string>

using namespace std ;

int main(){
    int ASCA[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
    char arr[200];
   scanf("%s",arr);
    string buf = arr;
    arr[buf.size()-1] = '\0';
    int count[26] = {0};
    for(int i = 0 ;i < 26 ; ++ i){
        for(int j = 0 ; j < buf.size() ; ++j) {
            if (ASCA[i] == buf[j]) {
                ++count[i];
            } else {
                count[i] = count[i];
            }

        }

    }
    for(int i= 0 ; i < 26; ++i) {
        printf("%c:%d\n", ASCA[i], count[i]);
    }
}

全部评论

相关推荐

今年读完研的我无房无车无对象,月入还没有过万&nbsp;看到他在朋友圈晒房产证,感叹自己白读了这么多年书
小浪_Coding:学历不代表就能赚多少钱, 自己硕士学历怎么说也是一方面好事, 工作只是为了谋生, 赚钱跟学历不挂钩, 看自己走什么样的路,做什么选择
点赞 评论 收藏
分享
每晚夜里独自颤抖:这个在牛客不是老熟人了吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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