Autor Tema: AYUDA CON DIAGRAMA DE FLUJO LAS TORRES DE HANOI  (Leído 8855 veces)

sandra84

  • Sin experiencia
  • *
  • Mensajes: 12
    • Ver Perfil
AYUDA CON DIAGRAMA DE FLUJO LAS TORRES DE HANOI
« en: 10 de Abril 2013, 09:50 »
HOLA:
NECESITO AYUDA PARA REALIZAR UN DIAGRAMA DE FLUJO  DE LAS TORRES DE HANOI CON 5 DISCOS, PRETENDO HACER LO CON IF

javi in the sky

  • Avanzado
  • ****
  • Mensajes: 393
    • Ver Perfil
Re:AYUDA CON DIAGRAMA DE FLUJO LAS TORRES DE HANOI
« Respuesta #1 en: 10 de Abril 2013, 11:05 »
¿A qué te refieres cuando dices que pretendes hacerlo con IF? ¿Te refieres a una herramienta para crear diagramas de flujo o a usar condicionales de tipo if ... then (si ocurre esto ... entonces ...)?

javi in the sky

  • Avanzado
  • ****
  • Mensajes: 393
    • Ver Perfil
Re:AYUDA CON DIAGRAMA DE FLUJO LAS TORRES DE HANOI
« Respuesta #2 en: 10 de Abril 2013, 11:08 »
Y otra cosa: el problema se puede resolver con recursividad o con iteración ¿sabes de qué manera lo tienes o quieres enfocar?

sandra84

  • Sin experiencia
  • *
  • Mensajes: 12
    • Ver Perfil
Re:AYUDA CON DIAGRAMA DE FLUJO LAS TORRES DE HANOI
« Respuesta #3 en: 11 de Abril 2013, 21:43 »
asi es perdon, con la condicion IF, realmente no se como hacerlo estoy en eso, estoy en pruebas de escritorio usando arreglos, ah se me hacen difíciles :o :o los diagramas de flujo!!

javi in the sky

  • Avanzado
  • ****
  • Mensajes: 393
    • Ver Perfil
Re:AYUDA CON DIAGRAMA DE FLUJO LAS TORRES DE HANOI
« Respuesta #4 en: 12 de Abril 2013, 13:48 »
Pienso que la información en esta página te puede ser útil: http://hanoitower.mkolar.org/algo.html ((incluso te da el código en c)

Hay diversos algoritmos pero si no quieres usar recursión hay una parte en la que explica cómo hacerlo con condicionales IF, donde dice:


I have formulated the following iterative algorithm for disk transfers, that can be easily converted into computer code:

Initial move:
    Disk 1 is moved to peg 3 if n is odd, and to peg 2 if n is even.
Subsequent moves depend on the parity of the disk transferred in the immediately preceding move:

        If its parity is even, the destination peg in the next move will remain the same, and the next disk will be transferred there from the peg that was not involved in the immediately preceding move (this disk will be placed on top of the previously transferred even disk, and therefore must be odd)
        If its parity is odd, the next transfer will be between pegs that are both different from the immediately preceding destination peg, and the direction of the move is such that a smaller disk is placed on top of a larger one.

In this algorithm it is assumed that the bases of the towers are all assigned the number n+1, and are treated as "disks" larger than all others. In this way, care is taken automatically of an empty peg.


A partir de esta idea se podría crear el código y el diagrama de flujo.


 

Sobre la educación, sólo puedo decir que es el tema más importante en el que nosotros, como pueblo, debemos involucrarnos.

Abraham Lincoln (1808-1865) Presidente estadounidense.

aprenderaprogramar.com: Desde 2006 comprometidos con la didáctica y divulgación de la programación

Preguntas y respuestas

¿Cómo establecer o cambiar la imagen asociada (avatar) de usuario?
  1. Inicia sesión con tu nombre de usuario y contraseña.
  2. Pulsa en perfil --> perfil del foro
  3. Elige la imagen personalizada que quieras usar. Puedes escogerla de una galería de imágenes o subirla desde tu ordenador.
  4. En la parte final de la página pulsa el botón "cambiar perfil".