@lastchance,
Yes, certainly swap is part of the algorithms library, hence my point
I doubt any of the algorithms are an option here |
...and, thus, rotate and shuffle.
However, @gongong will have to say if those algorithms are or are not possible in his code for an assignment (some professors specifically deny the use of libraries, functions or classes which have not yet been presented in lecture).
Certainly the sample output shows rotation for quick and brown, but again @gongong will have to answer as to what is to be chosen. The reversal isn't bad, if it qualifies for the assignment, though the center of an odd length sequence wouldn't move in such a case.
That brings up an interesting question for @gongong. The code presented uses the length member function of the string class. Noting the nature of the assignment, it seems clear to me that you are being tasked to look up the documentation for the string class to use what functions are documented there for this task.
For example, the [] operator on the string class is a member function.
There's also something to find a character in a string, and since spaces separate words, and separating words is apparently a required part of the assignment, could you use the string's function for searching for a character or would you have to avoid a string function not yet presented in class, thus requiring you to write your own?
Or, for that matter, can you use stringstream as in @lastchance's example?