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 207 views
1 answer 167 views
1 answer 197 views
1 answer 156 views
1 answer 168 views
1 answer 189 views
189 views asked Jul 29, 2020 by avibootz
...