题解 | #字母统计#

字母统计

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'};
    int count[26] = {0};
    char arr[100];
    scanf("%s",arr);
    string buf = arr;
    int len1 = buf.size();
    for(int i = 0 ; i < len1 ;++i){
        for(int j = 0 ; j < 26 ;++j){
         if(buf[i] == ASCA[j]){
            ++count[j];
        }else{
            continue;
        }
        }
    }
    for(int i = 0 ; i < 26 ;++i){
        printf("%c:%d\n",ASCA[i],count[i]);
    }
}

全部评论

相关推荐

点赞 评论 收藏
分享
05-26 22:25
门头沟学院 Java
Java小肖:不会是想叫你过去把你打一顿吧,哈哈哈
点赞 评论 收藏
分享
uu们,拒offer时hr很生气怎么办我哭死
爱睡觉的冰箱哥:人家回收你的offer,或者oc后没给你发offer的时候可不会愧疚你,所以你拒了也没必要愧疚他。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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