answersLogoWhite

0

Who does hangman mr Spencer?

User Avatar

Anonymous

12y ago
Updated: 8/20/2019

// Hangman

// The classic game of hangman

#include

<iostream>

#include

<string>

#include

<vector>

#include

<algorithm>

#include

<ctime>

#include

<cctype>

using

namespace std;

int

main()

{

//setup

const int MAX_WRONG = 8; //maximum number of incorrect guesses allowed

vector<string> words; //collection of possible words to guess

words.push_back(

"GUESS");

words.push_back(

"HANGMAN");

words.push_back(

"DIFFICULT");

srand(

static_cast<unsigned int>(time(0)));

random_shuffle(words.begin(), words.end());

const string THE_WORD = words[0]; //word to guess

int wrong = 0; //number of incorrect guesses

string soFar(THE_WORD.size(), '-'); //word guessed so far

string used = ""; //letters already guessed

cout <<

"Welcome to Hangman. Good luck!\n";

//main loop

while ((wrong < MAX_WRONG) && (soFar != THE_WORD))

{

cout <<

"\n\nYou have " << (MAX_WRONG - wrong);

cout <<

" incorrect guesses left.\n";

cout <<

"\nYou've used the following letters:\n" << used << endl;

cout <<

"\nSo far, the word is:\n" << soFar << endl;

char guess;

cout <<

"\n\nEnter your guess: ";

cin >> guess;

guess = toupper(guess);

//make uppercase since secret word in uppercase

while (used.find(guess) != string::npos)

{

cout <<

"\nYou've already guessed " << guess << endl;

cout <<

"Enter your guess: ";

cin >> guess;

guess = toupper(guess);

}

used += guess;

if (THE_WORD.find(guess) != string::npos)

{

cout <<

"That's right! " << guess << " is in the word.\n";

//update soFar to include newly guessed letter

for (int i = 0; i < THE_WORD.length(); ++i)

{

if (THE_WORD[i] MAX_WRONG)

{

cout <<

"\nYou've been hanged!";

}

else

{

cout <<

"\nYou guessed it!";

}

cout <<

"\nThe word was " << THE_WORD << endl;

return 0;

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

Why does Holden regret visiting Mr Spencer?

Holden visits Mr. Spencer to say Good-by.


Who is emperor Hangman Narnia?

The "Emperor's hangman" is the nickname that Mr. Beaver used to referred to the White Witch.


Why does Holden consider Mr Spencer phony?

Holden considers Mr. Spencer to be phony because he believes Mr. Spencer is insincere and pretentious. He perceives Mr. Spencer as someone who doesn't genuinely care about him but rather is just going through the motions of pretending to be concerned about his academic performance.


Who is Mr Spencer and why does Holden visit him?

Mr. Spencer was Holden's history teacher at Pencey Prep; he visits him because Mr. Spencer wanted to say goodbye to him and give him advice.


What do Mr Spencer and Holden exchange?

Mr. Spencer and Holden exchange ideas about Holden's academic performance and attitude towards school during their meeting. Mr. Spencer tries to counsel Holden about taking more responsibility and applying himself more diligently to his studies. Ultimately, Holden becomes frustrated with Mr. Spencer's well-meaning but condescending remarks.


Did holden opinion of mr Spencer go up or down during his visit?

His opinion of Mr. Spencer went down. He expected one thing to happen and he had a picture of what would happen when he visited the Spencer household. However, his expectations were squashed and he had to face the problems that Mr. Spencer posed when Holden was "let down."


How does holden describe mr and mrs Spencer?

Holden describes Mr. Spencer as old and boring, while he describes Mrs. Spencer as &quot;old and decrepit.&quot; He finds them both to be out of touch with his feelings and disinterested in his well-being.


Who does Holden talk to after the big fight?

Holden talks to his old history teacher, Mr. Spencer, after the big fight. They have a conversation at Mr. Spencer's house.


How did mr Spencer feel about holdens expulsion?

Mr. Spencer seemed disappointed and concerned about Holden's expulsion. He tried to have a serious talk with Holden to understand his situation and offer guidance, but Holden did not take it seriously. Overall, Mr. Spencer likely felt frustrated that Holden was not taking his future seriously.


Is Spencer silver the chemist the owner of the Spencer silver mansion?

No connection between Spencer Silver and the "Spencer Silver Mansion" in Havre de Grace, Maryland. This B&amp;B is owned by a Mr. Spencer and a Mr. Silver who combined their names for the B&amp;B. Spencer Silver


Does Holden's opinion of Mr Spencer improve or decline during his visit?

Holden's opinion of Mr. Spencer declines during his visit. He finds Mr. Spencer's lecture annoying and condescending, feeling that he doesn't genuinely care about his well-being. Holden becomes increasingly irritated and disengaged during the conversation.


What is the name of mr moseby's brother?

I believe it's Spencer