含e最多的单词


#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
int ce(string str)
{
    int count = 0;
    for (int i = 0; i < str.length(); i++)
    {
        if (str[i] == 'e')
            count++;
    }
    //cout << count << endl;计算e的个数
    return count;
}
int main()
{
    int maxe = 0;
    string maxstr;
    string str;
    cin >> str;
    string ss[25];
    int s = 0;
    while (str != "#")
    {
        if (ce(str) > maxe)
        {
            maxe=ce(str);
            s = 0;
            ss[s++] = str;
            //cout<<"new"<<endl;
        }
        else if (ce(str) == maxe)
        {
            ss[s++] = str;ji
            
            //cout<<'='<<endl;
        }
        cin >> str;
    }
    for (int i = 0; i < s; i++)
        cout << ss[i] << endl;
    return 0;
}

posted @ 2021-07-10 21:04  kubopiy  阅读(177)  评论(1编辑  收藏  举报