文章

113

粉丝

1

获赞

892

访问

96.7k

头像
字母统计 题解:c++,使用数组也能做
P1292 上海交通大学机试题
发布于 2026年2月
阅读数 992

#include <bits/stdc++.h>
using namespace std;

int main()
{
    string s ;
    while(cin >> s){
        int num[28] = {0};
        for(char a : s){
            if(a >= 'A' && a <= 'Z'){
                num[a-'A']++;
            }
        }
        for(int i = 0; i < 26; i++){
            cout << char('A' + i ) << ":" << num[i] << endl;
        }
    }
    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发