Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 2MotMystere.cpp : définit le point d'entrée pour l'application console.
- //
- #pragma once
- #include "targetver.h"
- #include <stdio.h>
- #include <tchar.h>
- #include <iostream>
- #include <string>
- //aléatoire
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- string melangeMot(string mot);
- int _tmain(int argc, _TCHAR* argv[])
- {
- string mot, motModifie, motUtilisateur;
- srand(time(0));
- cout << "Saisissez un mot" << endl;
- cin >> mot;
- motModifie = melangeMot(mot);
- do
- {
- cout << endl << "Quel est ce mot ? " << motModifie << endl;
- cin >> motUtilisateur;
- if (motUtilisateur == mot)
- cout << "Bravo !" << endl;
- else
- cout << "Ce n'est pas le mot !" << endl;
- }while (motUtilisateur != mot);
- cin.ignore();
- return 0;
- }
- string melangeMot(string mot)
- {
- int position(0);
- string motTemp;
- while(mot.size() != 0)
- {
- position = rand() % mot.size();
- motTemp += mot[position];
- mot.erase(position, 1);
- }
- return motTemp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement