C++ Array merge with merge() function

Description

C++ Array merge with merge() function

#include <iostream>
#include <algorithm>          //for merge()
using namespace std;
int src1[] = { 2, 3, 4, 6, 8 };
int src2[] = { 1, 3, 5 };
int dest[8];//from   w  ww  .ja  va 2s  . c  o  m
int main()
{                          //merge src1 and src2 into dest
    merge(src1, src1+5, src2, src2+3, dest);
    for(int j=0; j<8; j++)     // display dest
       cout << dest[j] << ' ';
    cout << endl;
    return 0;
}



PreviousNext

Related