#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
int random(int min, int max) {
return min + rand() % (max - min + 1);
}
string scramble(string word) {
if (word.length() <= 3) {
return word;
}
int pos1 = random(1, word.length() - 2);
int pos2 = random(1, word.length() - 2);
while (pos2 == pos1) {
pos2 = random(1, word.length() - 2);
}
swap(word[pos1], word[pos2]);
return word;
}
int main() {
srand(time(nullptr));
string word;
while (cin >> word) {
cout << scramble(word) << " ";
}
cout << endl;
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: