Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. river crossing priests and devils in c program

river crossing priests and devils in c program

Scheduled Pinned Locked Moved C / C++ / MFC
help
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 13623484
    wrote on last edited by
    #1

    Solution:
    To arrive all the priests and devils to the other side, 6 steps are to be followed:-

    1. Firstly one devil and one priest will go to the other side. Devil will stay to the other side while priest will come back with the boat.

    2. Remaining two devils will go to the other side.
      One devil will stay to the other side while one devil will come again with the boat.
      So total two devils are on the another side of river and 3 priests and 1 devil is on the one side of the river.

    3. Now two priests will go. One priest will stay while 1 priest and 1 devil come back with the boat.

    4. Now remaining two priests will go to the other side of the river.
      Total 3 priests and 1 devil is on the one side while 2 devils is on the another side of the river.
      1 devil will come back with the boat.

    5. 2 devils will go to the other side of the river. 1 devil will stay and 1 devil will again go back with the boat.

    6. Now the remaining 2 devils will come to the other side of the river.
      All the 3 priests and 3 devils arrive safely.

    kindly help this project

    L J D 3 Replies Last reply
    0
    • U User 13623484

      Solution:
      To arrive all the priests and devils to the other side, 6 steps are to be followed:-

      1. Firstly one devil and one priest will go to the other side. Devil will stay to the other side while priest will come back with the boat.

      2. Remaining two devils will go to the other side.
        One devil will stay to the other side while one devil will come again with the boat.
        So total two devils are on the another side of river and 3 priests and 1 devil is on the one side of the river.

      3. Now two priests will go. One priest will stay while 1 priest and 1 devil come back with the boat.

      4. Now remaining two priests will go to the other side of the river.
        Total 3 priests and 1 devil is on the one side while 2 devils is on the another side of the river.
        1 devil will come back with the boat.

      5. 2 devils will go to the other side of the river. 1 devil will stay and 1 devil will again go back with the boat.

      6. Now the remaining 2 devils will come to the other side of the river.
        All the 3 priests and 3 devils arrive safely.

      kindly help this project

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Help how? Since you have the solution you know what code to write.

      1 Reply Last reply
      0
      • U User 13623484

        Solution:
        To arrive all the priests and devils to the other side, 6 steps are to be followed:-

        1. Firstly one devil and one priest will go to the other side. Devil will stay to the other side while priest will come back with the boat.

        2. Remaining two devils will go to the other side.
          One devil will stay to the other side while one devil will come again with the boat.
          So total two devils are on the another side of river and 3 priests and 1 devil is on the one side of the river.

        3. Now two priests will go. One priest will stay while 1 priest and 1 devil come back with the boat.

        4. Now remaining two priests will go to the other side of the river.
          Total 3 priests and 1 devil is on the one side while 2 devils is on the another side of the river.
          1 devil will come back with the boat.

        5. 2 devils will go to the other side of the river. 1 devil will stay and 1 devil will again go back with the boat.

        6. Now the remaining 2 devils will come to the other side of the river.
          All the 3 priests and 3 devils arrive safely.

        kindly help this project

        J Offline
        J Offline
        jeron1
        wrote on last edited by
        #3

        At the top of this forum is a topic "How to ask a question", please read and pay particular attention to #2.

        "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

        1 Reply Last reply
        0
        • U User 13623484

          Solution:
          To arrive all the priests and devils to the other side, 6 steps are to be followed:-

          1. Firstly one devil and one priest will go to the other side. Devil will stay to the other side while priest will come back with the boat.

          2. Remaining two devils will go to the other side.
            One devil will stay to the other side while one devil will come again with the boat.
            So total two devils are on the another side of river and 3 priests and 1 devil is on the one side of the river.

          3. Now two priests will go. One priest will stay while 1 priest and 1 devil come back with the boat.

          4. Now remaining two priests will go to the other side of the river.
            Total 3 priests and 1 devil is on the one side while 2 devils is on the another side of the river.
            1 devil will come back with the boat.

          5. 2 devils will go to the other side of the river. 1 devil will stay and 1 devil will again go back with the boat.

          6. Now the remaining 2 devils will come to the other side of the river.
            All the 3 priests and 3 devils arrive safely.

          kindly help this project

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Member 13655542 wrote:

          kindly help this project

          Help or Do? If the former, what have you done (for us to help you with)?

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups