Retourner la position de la première paire des objets adjacents qui sont égaux

Author:

 iterator
{filelink=15445}

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

int main()
{
   vector vec;
   ostream_iterator output(cout," ");
   vec.push_back(1);
   vec.push_back(3);
   vec.push_back(2);
   vec.push_back(4);
   vec.push_back(6);
   vec.push_back(6);
   vec.push_back(0);

   copy(vec.begin(), vec.end(), output);

   cout<::iterator pos;
   pos = adjacent_find (vec.begin(), vec.end());

   if (pos != vec.end())
   {
       cout << "La position des deux premiers éléments qui sont égaux est: "
            << distance(vec.begin(),pos) + 1
            << endl;
   }else
   {
    cout<<"Aucune ressemblance consécutive dans la collection:"<
    

Leave a Reply

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