Question: C++ Rotate Vector Goal of the code: Your task is to shift a vector a certain amount of steps to the right. The right most
C++ Rotate Vector
Goal of the code: Your task is to shift a vector a certain amount of steps to the right. The right most element in the vector moves to the front as you shift. After the vector has been shifted, print out the contents with each element separated by a space. Example: Vector containing [ 1, 2, 3, 4, 5, 6, 7, 8, 9] shifted 4 times will be [ 6, 7, 8, 9, 1, 2, 3, 4, 5] Input:The first line will contain a number you need to shift by, and the second line will be space separated integers Output: Print out the contents of the vector with each element separated by a space.
Complete (fill in the blanks) and follow the instructions shown below in order to do the code.
#include
void rotateVector( std::vector
int main(){ // Read in the integer for the amount of shifts and save it to a variable. // Read the rest of the integers into a vector.
// Call the rotateVector() function on your vector. // Print out the contents of the vector. std::cout << std::endl; return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
