文章

20

粉丝

0

获赞

45

访问

1.5k

头像
字母统计 题解:
P1292 上海交通大学机试题
发布于2026年3月9日 21:45
阅读数 22

#include<iostream>
#include<string>
#include<stack>
#include<vector>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
    string str1;
    while(cin>>str1){
        vector<int>vec1(26,0);
        for(auto i:str1){
            if(i>='A'&&i<='Z'){
                vec1[i-'A']++;
            }
        }
        for(int i=0;i<vec1.size();i++){
            printf("%c:%d\n",'A'+i,vec1[i]);
        }
    }
    return 0;
}
 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发