#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
//Выбор слова дnя перемешивания
int main()
{
enum fields {WORD, HINT, NUM_FIELDS}; //перечислитель
const int NUM_WORDS = 5;
const string WORDS[NUM_WORDS][NUM_FIELDS] =
{
{"wall", "Do you feel you're banging your head against something?"},
{"glasses", "These might help you see the answer. "},
{"labored", "Going slowly. is it?"},
{"persistent", "Кеер at it."},
{"jumble", "It's what the game is all about."}
};
srand(static_cast<unsigned int>(time(0)));
int choice = (rand() % NUM_WORDS);
string theWord = WORDS[choice][WORD]; //слово которое нужно угадать
string theHint = WORDS[choice][HINT]; //подсказка для слова
//Перемешивание слова
string jumble = theWord; //jumble - перемешанный вариант слова
int length = jumble.size();
for(int i = 0; i < length; ++i) //меняет буквы местами
{
int index1 = (rand() % length);
int index2 = (rand() % length);
char temp = jumble[index1];
jumble[index1] = jumble[index2];
jumble[index2] = temp;
}
cout << "\t\t\tWelcome to Word JumЬle!\n\n";
cout << "Unscramble the letters to make а word. \n";
cout << "Enter 'hint' for а hint. \n";
cout << "Enter 'quit' to quit the game. \n\n";
cout << "The jumble is: " << jumble;
int score = 0;
string guess;
cout << "\n\nYour guess: ";
cin >> guess;
while((guess != theWord) && (guess != "quit"))
{
if(guess == "hint")
cout << theHint;
else
cout << "Sorry, that's not.";
cout << "\n\nUr guess: ";
cin >> guess;
}
if(guess == theWord){
cout << "\tThat's it! The next one: \n";
score += 100;
}
cout << "\tTX for playing\n\n";
system("pause");
return 0;
}
for(int i = 0; i < length; ++i) //меняет буквы местами
{
int prev = (rand() % (i+1));
char temp = jumble[prev];
jumble[prev] = jumble[i];
jumble[i] = temp;
}