Exemple d’utilisation de ‘merge()’ avec ‘ back_inserter()’

Author:

 iterator
{filelink=15241}


#include 
#include 
#include 
#include 

using namespace std;

int tab1[] = { 2, 3, 4, 6, 8 };
int tab2[] = { 1, 3, 5 };
int main( ) {

   vector v1(tab1, tab1+5), v2(tab2, tab2+3), v3;
   ostream_iterator< int > output( cout, " " );

   merge(v1.begin( ), v1.end( ),
         v2.begin( ), v2.end( ),
         back_inserter >(v3));

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

return 0;
}

 /*
abcdef
 */       

Leave a Reply

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