题解 | 字母统计

字母统计

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

#include <iostream>
using namespace std;

int main() {
    char arr[200];
    for(int i=0;i<26;i++){
        arr[i+'A']=0;
    }
    string s;
    while (getline(cin,s)) { // 注意 while 处理多个 case
        for(int i=0;i<s.length();i++){
            arr[s[i]]++;
        }
        for(int i=0;i<26;i++){
            printf("%c:%d\n",'A'+i,arr['A'+i]);
        }
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

海螺很能干:每次看到这种简历都没工作我就觉得离谱
点赞 评论 收藏
分享
吴offer选手:我卡在笔试才是最好笑的,甚至没给我发过笔试链接
投递哔哩哔哩等公司6个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务