统计字符数
#include <iostream> #include <map> using namespace std; int main(){ string n; map<char,int> a; cin>>n; int maxx = 0; char m; for(int i = 0;i<n.size();i++){ a[n[i]]++; } map<char,int> ::iterator i; for(i = a.begin();i!=a.end();i++){ if(i->second>maxx){ m = i->first; maxx = max(maxx,i->second); } } cout<<m<<" "<<maxx; return 0; }