Question
C++ PROGRAM: Create the function: int rotateLeft(string a[], int n, int pos); the functions you must write take 3 parameters. an array of strings a[]
C++ PROGRAM:
Create the function: int rotateLeft(string a[], int n, int pos);
the functions you must write take 3 parameters. an array of strings a[] , and the number of items the function will consider in the array n, starting from the beginning. And the third one is pos which you will Eliminate the item at position pos by copying all elements after it one place to the left. Put the item that was thus eliminated into the last position of the array. Return the original position of the item that was moved to the end. return 1 if they are passed any bad arguments (e.g. a negative array size, or a position that would require looking at the contents of an element past the last element we're interested in. Also, in the description of this function and the others, when we say "the array", we mean the n elements that the function is aware of. The one error your function implementations doesn't have to handle is when the caller of the function lies and says the array is bigger than it really is. Your program must not use any function templates from the algorithms portion of the Standard C++ library. examples:
string super[5] = { "logan", "clark", "peter", "sue", "reed" };
int m = rotateLeft(super, 5, 1); // returns 1
// super now contains: "logan", "peter", "sue", "reed", "clark"
---------------------
string super[5] = { "logan", "clark", "peter", "sue", "reed" };
int m = rotateLeft(super, 4, 4); // returns -1
// becasue the function is only aware of until "sue"
----------------------
string super[5] = { "logan", "clark", "peter", "sue", "reed" };
int m = rotateLeft(super, -7, 1); // returns -1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started