Rika_Z

guess phrases programm

Jul 25th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cstdlib>
  4. #include <ctime>
  5. #if defined(_WIN32) || defined(_WIN64)
  6. #pragma execution_character_set("utf-8")
  7. #include<Windows.h>
  8. const auto _dummy_ = []()
  9. {
  10.     SetConsoleCP(65001);
  11.     SetConsoleOutputCP(65001);
  12.     return 0;
  13. }();
  14. #endif
  15. using namespace std;
  16. int main()
  17. {
  18.     string phrase = "That who nothing to lose, is always has chanse to win. ";
  19.     string phraseCopy = phrase;
  20.     cout << "In this game you need guess end enter phrase without some words" << endl;
  21.     cout << "Enter how many words you need to destroy!(no more " << phrase.size() - 1<<")"<< endl;
  22.     unsigned int quantity;
  23.     cin >> quantity;
  24.     for (; quantity > 0; --quantity)
  25.     {
  26.         int randDestroy = (rand() % phrase.size()) + 1;
  27.         phrase[randDestroy] = 'X';
  28.     }
  29.     cout << phrase << endl;
  30.     cout << "Now, enter what phrase coding in here" << endl;
  31.     string phraseUser;
  32.     do
  33.     {
  34.         getline(cin, phraseUser);
  35.         if (phraseUser != phraseCopy)
  36.         {
  37.             cout << "Wrong, try againk" << endl;
  38.         }
  39.     } while (phraseUser != phraseCopy);
  40.     cout << "Fine good work!!!" << endl;
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment