Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,895 questions

51,826 answers

573 users

How to merge vector and a part of deque into a list in C++

1 Answer

0 votes
#include <iostream>
#include <algorithm>
#include <iterator>
#include <vector>
#include <deque>
#include <list>

using std::cout;
using std::endl;
using std::vector;
using std::deque;
using std::list;

int main()
{
	vector<char> vec = { 'a', 'c', 'e', 'h' };
	deque<char> dq = { 'b', 'd', 'e', 'f', 'g' };
	list<char> lst(9);

	merge(vec.begin(), vec.end(), dq.begin(), dq.begin() + 2, lst.begin());

	copy(lst.cbegin(), lst.cend(), std::ostream_iterator<char>(cout, " "));

	cout << endl;

	return 0;
}

/*
run:

a b c d e h

*/

 



answered Mar 1, 2018 by avibootz

Related questions

1 answer 187 views
1 answer 171 views
1 answer 188 views
1 answer 174 views
1 answer 168 views
2 answers 217 views
...