Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the following assignment in C++ *(Please do not use vectors or <algorith>

ID: 3723881 • Letter: W

Question

Write the following assignment in C++ *(Please do not use vectors or <algorith> we have not covered that yet in class) So this needs to be solved in a simple way.

Thanks

Write a function that accepts a word as an input argument (type string) and generates several different scrambles of the word. (Output to the screen.) The input word can be from 4 to 10 letters in length. The number of scrambles produced depends on the number of letters in the word. e.g. the 4 letter word “lose” would have 4 different scrambles produced and the seven letter word “edition” would have seven different scrambles. Here is a candidate example: Input: FLOOR Possible Scrambles: ROOLF, OOLFR, OLFRO, LOORF, OORFL Your function must use the same block of code for each input word. (That is you cannot test for the word length and then have special code depending on the result.) You have a number of tools available to assist with this including the reverse string operation you did in homework three. There is also the rand() random number generator available. Come up with your own algorithm for this problem.

Explanation / Answer

STL has a very handy function called rotate to help use left rotate a vector. We can make use of it to make different suffles.

Code:-

#include <iostream>

#include<vector>

#include<algorithm>

#include<string>

using namespace std;

int main() {

string s;

cin>>s;

vector<char> v;

for(int i=0;s[i]!='';i++)

{

v.push_back(s[i]);

}

  

  

for(int i=0;s[i]!='';i++)

{

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

for(int i=0;s[i]!='';i++)

{

cout<<v[i];

}

cout<<endl;

}

return 0;

}