Advertisement
villers

Untitled

Nov 24th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. // 2MotMystere.cpp : définit le point d'entrée pour l'application console.
  2. //
  3.  
  4. #pragma once
  5.  
  6. #include "targetver.h"
  7.  
  8. #include <stdio.h>
  9. #include <tchar.h>
  10. #include <iostream>
  11. #include <string>
  12.  
  13. //aléatoire
  14. #include <ctime>
  15. #include <cstdlib>
  16.  
  17. using namespace std;
  18.  
  19. string melangeMot(string mot);
  20.  
  21. int _tmain(int argc, _TCHAR* argv[])
  22. {
  23.     string mot, motModifie, motUtilisateur;
  24.     srand(time(0));
  25.  
  26.     cout << "Saisissez un mot" << endl;
  27.     cin >> mot;
  28.  
  29.     motModifie = melangeMot(mot);
  30.  
  31.     do
  32.     {
  33.         cout << endl << "Quel est ce mot ? " << motModifie << endl;
  34.         cin >> motUtilisateur;
  35.  
  36.         if (motUtilisateur == mot)
  37.             cout << "Bravo !" << endl;
  38.         else
  39.             cout << "Ce n'est pas le mot !" << endl;
  40.     }while (motUtilisateur != mot);
  41.  
  42.     cin.ignore();
  43.     return 0;
  44. }
  45.  
  46. string melangeMot(string mot)
  47. {
  48.     int position(0);
  49.     string motTemp;
  50.     while(mot.size() != 0)
  51.     {
  52.         position = rand() % mot.size();
  53.         motTemp += mot[position];
  54.         mot.erase(position, 1);
  55.     }
  56.     return motTemp;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement