Question

In: Computer Science

C++ PLEASE In the children’s game, Duck, Duck, Goose, a group of children sit in a...

C++ PLEASE

In the children’s game, Duck, Duck, Goose, a group of children sit in a circle. One of them is elected “it” and that person walks around the outside of the circle. The person who is “it” pats each child on the head, saying “Duck” each time, until randomly reaching a child that the “it” person identifies as “Goose.” At this point there is a mad scramble, as the “Goose” and the “it” person race around the circle. Whoever returns to the Goose’s former place first gets to remain in the circle. The loser of this race is the “it” person for the next round of play. The game continues like this until the children get bored or an adult tells them it’s snack time. Write software that simulates a game of Duck, Duck, Goose.

Solutions

Expert Solution

  1. First line of input contains T (1 <= T <= 50) number of test cases. First line of each case contains N (1 <= N <= 10000), number of students.
  2. Second line contains (N-1) integers, each integer is the number k (0 <= k <= 10^6) of times the teacher will say "duck" in the perticular round :

=======================================================================================

Save below code as .cpp extension format :

=======================================================================================
#include<iostream>
#include<vector>
#include<string>
#include<numeric>
using namespace std;

int main() {
int testCaseCount {};
cin >> testCaseCount;
for (int i = 0;i < testCaseCount;i++) {
//Get input
int playerCount {};
cin >> playerCount;
int duckCount[playerCount - 1];
for (int j = 0;j < playerCount - 1;j++)
cin >> duckCount[j];
//Declare initial variables
vector<int> players(playerCount);
iota(players.begin(),players.end(),1); //Range of position values
int currentPos = 0;
//Run simulation
for (int j = 0;j < playerCount - 1;j++) {
currentPos = (currentPos + duckCount[j]) % players.size();
players.erase(players.begin() + currentPos);
}
cout << "The winner student will be: " << players[0] << '\n';
}
return 0;
}

=======================================================================================

Below is the screen shot of above code with output :


Related Solutions

Problem 9: Duck Duck Goose JAVA Duck, duck, goose is a child's game where kids sit...
Problem 9: Duck Duck Goose JAVA Duck, duck, goose is a child's game where kids sit in a circle, facing inward, while another player, walks around calling each a "duck" until finally calling one a "goose". Given the number of kids seated in a circle, and the number of ducks called out, determine which child is the goose. Facts: ● The player circles the group in clockwise rotation ● Label the children numerically. ○ The first duck called is labeled:...
There is a popular game in the past where children sit on areca leaves and slide...
There is a popular game in the past where children sit on areca leaves and slide down from a higher surface to a lower surface, for example from the top of a small hill. The total mass of the frond and a childern is 67 kg and descends with an initial velocity of 43.3 m / s (assuming there is no friction between the frond and the soil). If then a force slows the movement of the fronds so that...
with C# FizzBuzz is a group word game for children to teach them about division. Players...
with C# FizzBuzz is a group word game for children to teach them about division. Players take turns to count incrementally, replacing any number divisible by three with the word fizz, any number divisible by five with the word buzz, and any number divisible by both with fizzbuzz. Some interviewers give applicants simple FizzBuzz-style problems to solve during interviews. Most good programmers should be able to write out on paper or whiteboard a program to output a simulated FizzBuzz game...
In this game, two players sit in front of a pile of 100 stones. They take...
In this game, two players sit in front of a pile of 100 stones. They take turns, each removing between 1 and 5 stones (assuming there are at least 5 stones left in the pile). The person who removes the last stone(s) wins. Write a program to play this game. This may seem tricky, so break it down into parts. Like many programs, we have to use nested loops (one loop inside another). In the outermost loop, we want to...
Children are playing a game of ice hockey on a frozen lake. One of the children...
Children are playing a game of ice hockey on a frozen lake. One of the children throws a 1200g water bottle with velocity 0.4 m/s to another kid, weighing 41 kg, sitting motionless on the ice who catches the bottle 0.2 m from their COM at angle of impact of 12 degrees. The child on the ice has a center mass moment of inertia of 38 kg m^2. Assuming the ice is perfectly friction-less, answer the following. 1.) How does...
You and your team of software developers are creating a game for children. The game has...
You and your team of software developers are creating a game for children. The game has different types of animals. As a team of software developers, create in a 1-page Word document the class "Animal," including appropriate methods and properties that are common to all animals, subclasses of Animal, such as Cats, Dogs, and Birds, and appropriate methods and properties unique to these subclasses.
Chicago is a group dice game that requires no skill. The objective of the game is...
Chicago is a group dice game that requires no skill. The objective of the game is to accumulate points by rolling certain combinations (GamezBuff, 2017). How do you play Chicago? There are eleven rounds in the game, one for each combination that can be made by adding two dice, namely the numbers two through 12. Each round has a target combination starting with two and going up all the way to 12. Going clockwise, the players take turns to roll...
Chicago is a group dice game that requires no skill. The objective of the game is...
Chicago is a group dice game that requires no skill. The objective of the game is to accumulate points by rolling certain combinations (GamezBuff, 2017). How do you play Chicago? There are eleven rounds in the game, one for each combination that can be made by adding two dice, namely the numbers two through 12. Each round has a target combination starting with two and going up all the way to 12. Going clockwise, the players take turns to roll...
Why is online marketing to children a controversial practice? What is the Children’s Online Privacy Protection...
Why is online marketing to children a controversial practice? What is the Children’s Online Privacy Protection Act (C O P P A) and how does it protect the privacy of children? How do companies verify the age of online users? Should companies be allowed to target marketing efforts to children under the age of 13?
••••Teaching Children to Communicate: Language, Literacy, and the Arts I. Children’s Language Development A. What is...
••••Teaching Children to Communicate: Language, Literacy, and the Arts I. Children’s Language Development A. What is The Critical Importance of Language Development? B. What are the Types of Language? C. What are some of the Language Differences in Children? D. Developmental Continuum: Oral Language? II. Effective Strategies to Promote Language Development A. How does of help Language Development in Babies and Toddlers? B. How does of help Preschoolers’ Language Development? III. Dual Language Learning A. What are some of the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT