Design and write a c++ code for the following game. A group of people plays this
ID: 646493 • Letter: D
Question
Design and write a c++ code for the following game. A group of people plays this game. The starts with one person holding a flag. The person holding the flag has to make a decision to knock one player out of the game.then he needs to pass the flag to another person. The next player holding the flag has to make similar decisions. The last player standing wins the game. The players are assigned numbers sequentially. The game starts by picking a random player to hold the flag and start the game. In this mode the player can knock only the player next in line.use arrays and display winner Design and write a c++ code for the following game. A group of people plays this game. The starts with one person holding a flag. The person holding the flag has to make a decision to knock one player out of the game.then he needs to pass the flag to another person. The next player holding the flag has to make similar decisions. The last player standing wins the game. The players are assigned numbers sequentially. The game starts by picking a random player to hold the flag and start the game. In this mode the player can knock only the player next in line.use arrays and display winner Design and write a c++ code for the following game. A group of people plays this game. The starts with one person holding a flag. The person holding the flag has to make a decision to knock one player out of the game.then he needs to pass the flag to another person. The next player holding the flag has to make similar decisions. The last player standing wins the game. The players are assigned numbers sequentially. The game starts by picking a random player to hold the flag and start the game. In this mode the player can knock only the player next in line.use arrays and display winnerExplanation / Answer
// In this program, I have taken 5 elements in the array, whose values are 1,3,5,7,9. I am selecting an element and knocking out the element at 0th index, then showing remaining elements in the array. Again selecting the index 0 and knocking it out, and showing the leftover list and so on until just one is left.
# include <iostream.h>
# include <algorithm.h>
#include<random.h>
Int main()
{
Int n[]={1,3,5,7,9};
Std::size_t n_size= sizeof(n) / sizeof(int);
Std::random_number generator;
For(std::size_t i(0),sz(n_size); i<sz; ++i)
{
Std::cout<<
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.