Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <ctime>
- #include <cstdlib>
- using namespace std;
- int main(){
- enum fields {WORD, HINT, NUM_FIELDS};
- const int NUM_WORDS = 5;
- const string WORDS [NUM_WORDS][NUM_FIELDS] = // WORDS[5][2]
- {
- {"Danil", "it's my name"},
- {"Bogdan", "name of my friend"},
- {"Oksana", "name of my mother"},
- {"Sasha", "name of my father"},
- {"Eugen", "name of my brother"}
- };
- srand(static_cast<unsigned int>(time(0))); // эта строка для того, чтобы был рандом разный при каждом новом запуске
- int choise = (rand() % NUM_WORDS);
- string theWord = WORDS[choise][WORD]; // слово, которое нужно отгадать
- string theHint = WORDS[choise][HINT]; // подсказка, для слова
- string jumble = theWord;
- 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 Jumble!\n\n";
- cout << "Unscrambl е the letters to make а word. \n";
- cout << "Enter 'hint' for а hi nt. \n";
- cout << "Enter 'quit' to quit the game. \n\n";
- cout << "The jumble is: " << jumble;
- string guess;
- cout << "\n\nYour guess: ";
- cin >> guess;
- int minus_score = -2;
- while((guess != theWord) && (guess != "quit"))
- {
- if (guess == "hint")
- {
- cout << theHint;
- cout << "\nYour score is: " << minus_score << "\n";
- cin >> guess;
- cout << "\nYour score is: " << theWord.size() + minus_score;
- }else
- {
- cout << "Sorry, but it's not this";
- }
- cout << "\nYour guess: ";
- cin >> guess;
- }
- if(guess == "quit")
- {
- cout << "\nLooser";
- }
- else if(guess == theWord)
- {
- cout << "\nWow it's impossible";
- cout << "\nYour score is: " << theWord.size();
- }
- cout << "\nThank you for playing";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement