题解 | 字母统计

字母统计

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

#include <iostream>
#include <string>
using namespace std;
int main() {
    int res[26]={0};
    string str;
    char c[1024];
    scanf("%s",c);
    str = c;
    for(int i=0;i<str.size();i++){
        int ascii = str[i];
        if(str[i]>='A'&&str[i]<='Z'){
            res[ascii-65]++;
        }
    }
    for(int i=0;i<26;i++){
        printf("%c:%d\n",i+65,res[i]);
    }
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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