Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
GreenGeeks Web Hosting - Faster, Scalable & Eco-Friendly

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Distribute your Resume to 500+ Job Boards & Recruiters


8,120 questions

11,301 answers

573 users

How to remove specific value from vector1 and copy the result into vector2 in C++

1 Answer

0 votes
#include <iostream>
#include <vector>
#include <algorithm>

using std::cout;
using std::endl;
using std::vector;

int main()
{
	vector<int> vec1 = { 9, 1, 2, 3, 4, 1, 2, 3, 5, 1, 2, 3 };
	vector<int> vec2(12);

	remove_copy(vec1.begin(), vec1.end(), vec2.begin(), 1);

	for (vector<int>::iterator it = vec2.begin(); it != vec2.end(); it++)
		cout << ' ' << *it;

	cout << endl;

	return 0;
}


/*
run:

9 2 3 4 2 3 5 2 3 0 0 0

*/

 




answered May 17 by avibootz
...