Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <random>
- #include <chrono>
- using namespace std;
- string melangeLettre(string mot);
- int main()
- {
- cout << "Saisissez un mot mystere: n> ";
- string motMystere{};
- cin >> motMystere;
- cout << "Quel est ce mot ?n";
- string const newMot{melangeLettre(motMystere)};
- cout << newMot << endl;
- return {0};
- }
- string melangeLettre(string mot)
- {
- size_t random = chrono::system_clock::now().time_since_epoch().count();
- mt19937 gen{random};
- string newMot{};
- for (unsigned int i{}; i < mot.size(); ++i)
- {
- uniform_int_distribution<> getNbr(0, mot.size());
- int const alea{mot[getNbr(gen)]};
- newMot.push_back(alea);
- mot.erase(alea, 1);
- }
- return newMot;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement