How to rotate a sequence in vector with C++

1 Answer

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

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

int main()
{
	vector<double> vec{ 0, 1, 2, 3, 4, 5 };

	rotate(vec.begin(), vec.begin() + 1, vec.end());

	for (double val : vec)
		cout << val << " ";
	
	cout << endl;

	return 0;
}

/*
run:

1 2 3 4 5 0

*/

 



answered May 2, 2018 by avibootz

Related questions

...