题目链接:http://acm.nefu.edu.cn/JudgeOnline/problemshow.php?problem_id=520
#include <iostream> #include <cstring> #include <algorithm> using namespace std; char str[105]; int main() { while(cin>>str) { int sum[7]={0}; int len=strlen(str); for(int i=0; i<len; i++) { if(str[i] == 'a') sum[0]++; if(str[i] == 'b') sum[1]++; if(str[i] == 'c') sum[2]++; if(str[i] == 'd') sum[3]++; if(str[i] == 'e') sum[4]++; if(str[i] == 'f') sum[5]++; if(str[i] == 'g') sum[6]++; } sort(sum,sum+7); cout<<sum[6]<<endl; } return 0; }
简单统计排序