C++: Rechercher la première occurence d’un objet dans le deque

Author:

 assert, deque
{filelink=14998}


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

int main()
{
   deque deq;

  deq.push_back(-9);
  for(int i=1;i<9;i++)
	   deq.push_back(i);

  for(int y=0;y::iterator iter = find(deq.begin(), deq.end(), 5);
  cout << *iter << endl;

   if( iter != deq.end() )
   cout << "n5 trouvé à l'index " << (iter-deq.begin() );
     else
   cout << "n5 intyrouvable.";

  return 0;
}

Leave a Reply

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