| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Sorting Game

Page history last edited by Steve Sweeney 13 years, 4 months ago

Write a program to play the following game:  Begin by displaying the ten digits 0 to 9 in some random order.  Repeatedly ask the player to choose a number n, after which the computer will reverse the first n digits in the sequence.  The object of the game is for the player to put all the digits in ascending order using as small a number of reversals as possible.  Set up your program so that after each game it asks if the game should be repeated with the same starting sequence, played with a new starting sequence, or terminated.

Comments (0)

You don't have permission to comment on this page.