Afficher les entrées claviers sans doublon à l’aide de la fonction objet ‘istream_iterator’

Author:

 iterator
{filelink=15192}

#include 
#include 
#include 
#include 
#include 
using namespace std;

int main()
{
    vector coll(5);

   cout << "Tapez 5 chaînes de caractères: ";
   istream_iterator cin_iter(cin);
   istream_iterator end_of_stream;   

    copy (cin_iter, end_of_stream, coll.begin());           

    // Trier les éléments
    sort (coll.begin(), coll.end());

   //Afficher les éléments sans doublon
    unique_copy (coll.begin(), coll.end(),
                 ostream_iterator(cout," "));
	return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *