Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///Trello, Principiante, Letras Extremas
- #include <iostream> /// AlenAntonelli
- #include <vector>
- using namespace std;
- int main ()
- {
- int N=0, cmax=0, ban; /// N: cantidad de palabras. cmax: veces que se usa la/s extrerna mas usada
- char tl[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};///vector con 26 contadores
- vector <char> le, mle;///vectores que almacenen todas las letras externas y las mas usadas
- vector <int> tc (26, 0);///vector con 26 letras
- vector <string> v; /// vector de palabras
- string aux; /// string auxiliar utililizada en los ingresos de cada palabra al...
- cin >> N;
- for (int i=0; i<N; i++)
- {
- cin >> aux;
- v.push_back ( aux );
- }
- for (int i=0; i<N; i++)
- {
- le.push_back(v[i][0]);
- le.push_back(v[i][ v[i].size()-1 ]);
- }
- for (int i=0; i<le.size(); i++)
- {
- ban=1;
- for (int c=0; ban==1; c++)
- if(tl[c]==le[i])
- {
- tc[c]++;
- ban=0;
- }
- }
- for (int c=0; c<26; c++)
- if ((tc[c] != 0) && (tc[c] > cmax))
- cmax = tc[c];
- for (int c=0; c<26; c++)
- if (tc[c]==cmax)
- mle.push_back(tl[c]);
- for (int i=0; i<mle.size(); i++)
- {
- cout <<mle[i]<<" ";
- if (i != mle.size()-1)
- cout<<" ";
- }
- for (int i=0; i<N; i++)
- {
- ban=1;
- for (int j=0; j<mle.size() && ban==1; j++)
- if ( ( v[i][0] == mle[j] ) || ( v[i][v[i].size()-1] == mle[j] ) )
- {
- cout << endl << v[i];
- ban=0;
- }
- }
- return N;
- }
Advertisement
Add Comment
Please, Sign In to add comment