Advertisement
Gustavo_Inzunza

ayudantia 5

Sep 6th, 2013
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     string nombre;
  9.     vector< string > lista;
  10.     int numero,mayor=0,pos,n;
  11.     map<string,int> nombres;
  12.     map<string,int> ::iterator p;
  13.     cout<<"ingrese cantidad de datos que desea ingresar:";
  14.     cin>>n;
  15.     for(int i=0;i<n;i++)
  16.     {
  17.       cout<<"Ingrese nombre y su numero:";
  18.       cin>>nombre>>numero;
  19.       nombres[nombre]=numero;
  20.     }
  21.     cout<<"ingrese cantidad de datos que desea eliminar:";
  22.     cin>>n;
  23.     for(int i=0;i<n;i++)
  24.     {
  25.         cout<<"ingrese nombre a eliminar:";
  26.         cin>>nombre;
  27.         p=nombres.find(nombre);
  28.         if(p!=nombres.end())
  29.             nombres.erase(p);
  30.         else
  31.             cout<<"nombre no existe"<<endl;
  32.     }
  33.     p=nombres.begin();
  34.     while(p!=nombres.end())
  35.     {
  36.       lista.push_back(p->first);
  37.       p++;
  38.     }
  39.     for(int veces=0;veces<3;veces++)
  40.     {
  41.         mayor=-1,pos=-1;
  42.         for(int i=0;i<lista.size();i++)
  43.         {
  44.             int cont=0;
  45.             for(int j=0;j<lista[i].size();j++)
  46.                 if(lista[i][j]=='a' || lista[i][j]=='e' || lista[i][j]=='i' || lista[i][j]=='o' || lista[i][j]=='u')
  47.                     cont++;
  48.             if(cont>mayor)
  49.             {
  50.                 pos=i;
  51.                 mayor=cont;
  52.             }
  53.         }
  54.         cout<<lista[pos]<<endl;
  55.         lista.erase(lista.begin()+pos);
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement