Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

image text in transcribed
(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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

Students also viewed these Databases questions

Question

1. Outline the listening process and styles of listening

Answered: 1 week ago

Question

4. Explain key barriers to competent intercultural communication

Answered: 1 week ago