#include #include #include #include using namespace std; int main() { int count; 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?" }, { "persistant", "Keep at it." }, { "jumble", "It's what the game is all about." } }; srand(static_cast(time(0))); int choice = (rand() % NUM_WORDS); string theWord = WORDS[choice][WORD]; //word to guess string theHint = WORDS[choice][HINT]; //hint for word string jumble = theWord; //jumbled version of word 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; count = length; } cout << "\t\t\tWelcome to Word Jumble!\n\n"; cout << "Unscramble the letters to make a word.\n"; cout << "Enter 'hint' for a hint.\n"; cout << "Enter 'quit' to quit the game. \n"; cout << "You will start out with the same number of points as letters in your word.\n"; cout << "Asking for a hint will give you -2 points and every wrong answer will give you -1 point.\n"; cout << "Try to guess the word jumble with as many points as possible!\n\n"; cout << "The jumble is: " << jumble; string guess; cout << "\n\nYour guess: "; cin >> guess; while ((guess != theWord) && (guess != "quit")) { if (guess == "hint") { count = count - 2; cout << theHint << "\n"; cout << "You now have " << count << " points remaining"; } else { count = count - 1; cout << "Sorry, that's not it.\n"; cout << "You now have " << count << " points remaining"; } cout << "\n\nYour guess: "; cin >> guess; } if (guess == theWord) { cout << "\nThat's it! You guessed it!\n"; cout << "Your score is: " << count << "\n"; } system("pause"); return 0; }