How to remove the first and last elements of a deque in C++

1 Answer

0 votes
#include <iostream>  
#include <string>  
#include <deque> 

using std::deque;
using std::string;
using std::cout;

int main()
{
	deque<string> dq{ "c++", "c", "assembly", "c#", "java" };

	dq.pop_front();
	dq.pop_back();

	for (auto elem : dq) {
		cout << elem << ' ';
	}
	cout << std::endl;

	return 0;
}

/*
run:

c assembly c#

*/

 



answered Jan 4, 2018 by avibootz

Related questions

2 answers 358 views
1 answer 273 views
1 answer 292 views
1 answer 277 views
1 answer 255 views
1 answer 266 views
266 views asked Jul 29, 2020 by avibootz
...