Advertisement
Mastercpp

Untitled

Sep 3rd, 2015
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. #include <vector>
  5. using namespace std;
  6.  
  7.  
  8. int main(){
  9.  
  10.     int cantidad_nombres;
  11.  
  12.     cout << "Cuantos nombres quieres ingresar? :";
  13.     cin>>cantidad_nombres;
  14.  
  15.     string nombres[cantidad_nombres];
  16.  
  17.     for(int i =0; i<cantidad_nombres; i++){
  18.         cout << "ingrese el nombre " << i+1 << " : ";
  19.         cin>>nombres[i];
  20.     }
  21.  
  22.     vector<string> lista_nombres(nombres,nombres+cantidad_nombres);
  23.  
  24.  
  25.     cout << "\t\t\tPresentando los nombres: " << endl;
  26.  
  27.     vector<string>::iterator it = lista_nombres.begin();
  28.     sort(lista_nombres.begin() , lista_nombres.end());
  29.     while(it != lista_nombres.end()){
  30.         cout << *it << endl;
  31.         *it++; 
  32.     }
  33.  
  34.     cin.get();
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement