1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
#include <string>
#include <cstdlib>
#include <ctime>
//#include <stdio.h>
#include <iostream>
int main()
{
using namespace std ;
int score,choice,length;
string theword, thehint,jumble;
score = 0;
enum fields {WORD, HINT, NUM_FIELDS};
const int NUM_WORDS = 12;
const string WORDS[NUM_WORDS][NUM_FIELDS] =
{
{"door", "Pasukan ito!"},
{"mouse", "Small and eats cheese."},
{"candle", "ginagamit pag brownout"},
{"cocoa", "Uses to make chocolate."},
{"television", "What you watch your shows on."},
{"paul", "my name"},
{"paper","madalas hinihingi ng estudyante"},
{"wall", "Do you feel like banging your head against something?"},
{"glasses", "These might help you see the answer" },
{"friend", "kami ito. pede ba yon? " },
{"computer", "naadik na mga kabataan dito"},
{"jumble", "It's what the game is all about!",}
};
srand(time(0));
choice = (rand() % NUM_WORDS);
theword = WORDS[choice][WORD];
thehint = WORDS[choice][HINT];
jumble = theword;
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;
score = length;
}
cout << "\t\t\t**************************\n" ;
cout << "\t\t\t* JUMBLED WORD PROGRAM *\n" ;
cout << "\t\t\t**************************\n" ;
cout << "\n" ;
cout << "\n" ;
cout << " -------------------------------\n" ;
cout << "| Enter 'hint' for a hint. |\n" ;
cout << "| Enter 'quit' to quit the game.|\n" ;
cout << " -------------------------------\n\n" ;
cout << "SIMULAN NA ANG LARO!!!\n\n\n\n" ;
cout << "The jumble is " << jumble ; // cout<< "The jumble is" << jumble;
string guess;
cout << "\n\nYour guess: " ;
cin >> guess;
while ((guess != theword) && ( guess != "quit"))
{
if (guess == "hint")
cout << thehint; // cout<<thehint
else
cout << "Sorry that is not it..." ;
--score;
cout << "\n\nYour guess: " ;
cin >> guess ; // cin>> guess;
}
if (guess == theword)
cout << "\nThat's it! You guessed it! You have a score of " << score << '\n' ;
cout << "\nThanks for playing!\n" ;
}
|