文章

13

粉丝

0

获赞

34

访问

2.0k

头像
统计字符数 题解:
P5293 北京大学2025年机试题
发布于2026年3月16日 17:28
阅读数 107

#include <bits/stdc++.h>  //H-统计字符数 
using namespace std;
int main()
{
    string s;
    while(cin>>s)
    {
        vector<int>vec(26,0);//0-25
        for(int i=0;i<s.size();i++)
        {
            vec[(s[i]-'a')]++;
        }
        int max=0;//统计最大数个数
        int x=0;//最大数下标 
        int count=0;//记录字符出现相同的个数 
        for(int j=0;j<26;j++)
        {
            if(vec[j]>max) 
            {
             &nb...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发