#include<iostream> //for cin and cout
#include<vector> //for vector
#include<iterator> //for erase method
using namespace std;
//main method
int main()
{
int x,n; //to store the passes and number of players.
char again; //to store the choice of user to play again
do{
cout<<"Enter number of passes: ";
cin>>x;
cout<<"Enter number of players: ";
cin>>n;
x = (n>0)?x%n:0; //decrements the passes
vector<int> players; //creates a vector which represents
players.
//populates the players indices
for(int i=1;i<=n;i++){
players.push_back(i);
}
//iterator helps in erasing(deleting) value from vector
vector<int>::iterator it = players.begin();
int pos = 0;
//loop continues until size is greater than 1
while(players.size()>1){
for(int i=1;i<=x;i++){ //loops passes times
++pos;
if(pos==players.size())//if pos is equal to size then
pos = 0; //assigns 0.
}
it = players.begin()+pos;
players.erase(it); //removes the value from vector
if(pos==players.size())
pos = 0;
}
//prints the winner
cout<<"\nPlayer "<<players[0]<<"
Won"<<endl;
//prompts the user for playing again
cout<<"\nDo you want to play again(y/n)? ";
cin>>again;
cout<<endl;
}while(again=='y'); //loop continues if user enters y
return 0;
}
//output screenshot

//any query, post in the comment section
C++ Implement Hot Potato game ________________________________________________ A group of people, numbered 1 to N, are sitting...
1. NIM game. This is a different version or easier version of NIM game Consider a pile of 5 matchsticks. Two people take turns removing 1 or 2 sticks each time from this pile. Suppose both players play smartly (nobody plays a fool move trying to let the opponent wins. But there is only one winner anyway) a)If the person getting the last stick wins, will the first player win? Why? Show the steps the first and second player will...
C++ Hangman (game) In this project, you are required to implement a program that can play the hangman game with the user. The hangman game is described in https://en.wikipedia.org/wiki/Hangman_(game) . Your program should support the following functionality: - Randomly select a word from a dictionary -- this dictionary should be stored in an ASCII text file (the format is up to you). The program then provides the information about the number of letters in this word for the user to...
Create a JavaFX game: Guess the Number create a random # between 1 and 1000 Ask user for a guess; possible answers TOO LOW TOO HIGH WINNER! print guess to screen if the user wins, write the random number, and all the guesses to a file. If the user doesn't guess in 10 turns, display the number. NOTES: You may want to implement: Restart option Best Guess statistic (game 1 took 8 tries, game 2 took 5 - 5 is...
need help, dont understand how to set up.
1 You are a game developer at Microsoft Corporation and are charged with the task of developing games in C++. 2 Please develop a Rock Paper Scissor game for two players. Each player should have one of the following options: • 1. Rock • 2. Paper • 3. Scissor A. Player One: person You need to ask the person to enter one option from the above three. 10 B. Player Two: computer...
This program should be in c++. Rock Paper Scissors: This game is played by children and adults and is popular all over the world. Apart from being a game played to pass time, the game is usually played in situations where something has to be chosen. It is similar in that way to other games like flipping the coin, throwing dice or drawing straws. There is no room for cheating or for knowing what the other person is going to...
python question
Question 1 Write a Python program to play two games. The program should be menu driven and should use different functions to play each game. Call the file containing your program fun games.py. Your program should include the following functions: • function guess The Number which implements the number guessing game. This game is played against the computer and outputs the result of the game (win/lose) as well as number of guesses the user made to during the...
I need help figuring out how to code this in C++ in Visual Studio. Problem Statement: Open the rule document for the game LCR Rules Dice Game. Develop the code, use commenting to describe your code and practice debugging if you run into errors. Submit source code. Use the document to write rules for the user on how to play the game in a text file. Then, using the information from the resource articles, create a program that will read...
In need of some help with a LCR C++ game. The code will run, but I need it to cycle through the turns automatically so that the only input from the user is the number of players. It's also showing the winner as the person with 0 chips which is incorrect and I can't figure out why. Any help is greatly appreciated as this is already late. Game rules: Develop a program that follows the rules of Left Center Right...
Consider a group ofn 4 people, numbered from l to n. For each pair (i, j) with ǐ关į person i and person J are friends, with probability p. Friendships are independent for different pairs. These n people are seated around a round table. For convenience, assume that the chairs are numbered from 1 to n, clockwise, with n located next to 1, and that person i seated in chair i. In particular, person 1 and person n are seatec next...
Using python 3.7.3 Challenge: Rock, Paper, Scissors GamePDF Description: Create a menu-driven rock, paper, scissors game in Python 3 that a user plays against the computer with the ability to save and load a game and its associated play statistics. Purpose: The purpose of this challenge is to assess the developer’s ability to create an interactive application with data persistence in Python 3. Requirements: Create a Rock, Paper, Scissors game in Python named rps.py according to the requirements specified in...