Question: (20 pts) Let's play a game! In the beginning, we have N mmber of people standing in a circle waiting to be eliminated. The counting

 (20 pts) Let's play a game! In the beginning, we have

(20 pts) Let's play a game! In the beginning, we have N mmber of people standing in a circle waiting to be eliminated. The counting begins at some point in the circle and is counted clockwise. During the counting, k number of people are skipped and the next person is eliminated. The elimination proceeds around the circle until the last person standing wins the game. Write some codes that will play the game for a set of inputs and return the initial position of the player who won the game. You must use the rand() function to generate a number ranged from 3 to 7 for the value of k Sample Input: N= 10 k=5 The starting point is 3. Therefore, (3 4 5 6 7 8 9 10 1 2 Sample Output: 1" elimination (9,10,1,2,3,4,5,6,7) 2nd elimination (5.6.7.9.10.1.2,3) 3rd elimination 2.3.5.6.7.9.10) 4th elimination (10,2,3,5,6,71 5th climination [10.2,3,5,6 6th elimination (2,3,5,6) 7th elimination 15.6.2 gth elimination 15.6] gth elimination (5) Therefore, the person in the 5th position is the winner of the game

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!