#include<string> #include<iostream> #include<sstream> using namespace std; int main() { string in; cin >> in; int len = in.length(); int temp[26] = { 0 }; for (int i = 0; i < len; i++) { int t = in[i] - ‘a‘; temp[t]++; } int res = 0; for (int i = 0; i < 26; i++) { if (temp[i] > res) res = temp[i]; } cout << res; }
我:
string str; //cout<<"输入:"; cin>>str; int length=str.length(); map<char,int> mp; for(int i=0;i<length;i++) { mp[str[i]]++; } int size=mp.size(); int temp=0; int j; for( j=0;j<size;j++) { if(mp[str[j]]>temp) { temp= mp[str[j]]; } } cout<<temp;
原文地址:https://www.cnblogs.com/cgy1012/p/11441060.html
时间: 2024-10-27 03:03:52