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 230 views
1 answer 182 views
1 answer 214 views
1 answer 161 views
1 answer 174 views
1 answer 195 views
195 views asked Jul 29, 2020 by avibootz
...