dj
2024-10-11 19:20:14
发布于:上海
1阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
int a[26] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
for(int i = 0;i<s.size();i++){
a[s[i]-'a']++;
}
int maxn = 0;
int ans = -1;
for(int i = 25;i>=0;i--){
if(a[i]>=maxn)
{
maxn = a[i];
ans = i;
}
}
char ansc = ans+'a';
cout<<ansc;
}
这里空空如也
有帮助,赞一个