C Programming Josephus Problem

This is a discussion on C Programming Josephus Problem within the C Programming forums, part of the General Programming Boards category; I need help for this question... plz... PART B: JOSEPHUS PROBLEM Consider the following scenario - a group of soldiers ...

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    1

    C Programming Josephus Problem

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

    PART B: JOSEPHUS PROBLEM

    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,751
    Thank you for your post

    Please read this before dumping your homework without any effort again
    http://cboard.cprogramming.com/annou...ouncementid=39

    Is this new to you, or pointless?
    http://www.google.com/search?q=JOSEPHUS+PROBLEM
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 03:51 PM
  2. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM
  3. Please , i need help with this Josephus Problem
    By Haytham in forum C Programming
    Replies: 17
    Last Post: 04-07-2007, 08: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21