Thread: C Programming Josephus Problem

  1. #1
    Registered User
    Join Date
    May 2005

    C Programming Josephus Problem

    I need help for this question... plz...


    Consider the following scenario - a group of soldiers surrounded by an overwhelming enemy force. There is no hope for victory without reinforcements, but there is only a single horse available for escape. The soldiers agree to a pact to determine which of them is to escape and summon help. They stand in a circle and each picks a number from a hat. One of their names is also picked from the hat. Starting with the soldier whose name is picked and the nth number he chose, they count around the circle clockwise and eliminate the nth person. The number that this soldier chose is then used to continue the count. Each time that a soldier is eliminated, the number that he chose is then used to continue the count. Any soldier removed from the circle is no longer counted. The last soldier remaining is to take the horse and escape.

    The input to the program is a list of names, which is the clockwise ordering of the circle beginning with the soldier from whom the count is to start. The program must print the names in the order in which they are eliminated and the name of the soldier who escapes.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Thank you for your post

    Please read this before dumping your homework without any effort again

    Is this new to you, or pointless?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  2. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  3. Please , i need help with this Josephus Problem
    By Haytham in forum C Programming
    Replies: 17
    Last Post: 04-07-2007, 07:28 PM
  4. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  5. The Josephus Problem
    By Nakeerb in forum C++ Programming
    Replies: 5
    Last Post: 11-21-2002, 08:43 AM