文章

2

粉丝

261

获赞

2

访问

16.9k

头像
第一想法就是用string做,请各位多指教
P1019 贵州大学机试题
发布于2020年3月13日 23:53
阅读数 7.8k

#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    getline(cin,s);
    int pos=0;
    int a[26]={0};
    transform(s.begin(),s.end(),s.begin(),::tolower);
    t=s;
    for(int i=0;i<=25;i++){
        char c='a'+i;
        while((pos=t.find(c))!=-1){
            t.erase(pos,1);
            a[i]++;
        }
        t=s;
    }
    char c='a'+(max_element(a,a+26)-a);
    cout<<c<<" "<<(*max_element(a, a + 26));

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发