Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///Trello, Principiante, Letras extremas
- #include <iostream> /// AlenAntonelli
- #include <vector>
- #include <map>
- using namespace std;
- int main ()
- {
- int N, may, ban;
- vector <char> MLE;
- cin>>N;
- cout<<endl;
- vector <string> nombres (N);
- map <char, int> mapa;
- for (int i=0; i<N; i++)
- {
- cin>>nombres[i];
- if (nombres[i].size()>1)
- {
- mapa[ nombres[i].front() ]++; ///magic line
- mapa[ nombres[i].back() ]++; ///magic line
- }
- else
- mapa[ nombres[i][0] ]++;
- }
- map <char, int>::iterator it = mapa.begin();
- for (int i=0; it!=mapa.end(); it++, i++)
- {
- if (i==0)
- may=(*it).second;
- else
- if ((*it).second > may)
- may=(*it).second;
- }
- it = mapa.begin();
- for (int i=0; it!=mapa.end();it++, i++)
- if ((*it).second == may)
- MLE.push_back( (*it).first );
- cout<<endl<<endl;
- for (int i=0; i<MLE.size(); i++)
- cout<<MLE[i]<<" ";
- for (int i=0; i<N; i++)
- for (int j=0; j<MLE.size(); j++)
- if ( ( nombres[i].front() == MLE[j] ) || ( nombres[i].back() == MLE[j] ) )
- {
- cout << endl << nombres[i];
- break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment