Demonstrate remove_copy in Vector
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
vector<int> v, vectorObject2(20);
int i;
for(i = 0; i <20; i++) {
if(i%2) v.push_back(1);
else v.push_back(2);
}
cout << "Sequence: ";
for(i = 0; i <v.size(); i++)
cout << v[ i ] << " ";
cout << endl;
remove_copy(v.begin(), v.end(), vectorObject2.begin(), 1);
cout << "Result: ";
for(i = 0; i <vectorObject2.size(); i++)
cout << vectorObject2[ i ] << " ";
cout << endl << endl;
return 0;
}
Related examples in the same category