¿Algoritmo del juego torre de hanói?
Respuestas a la pregunta
sing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string d3="3", d2="2", d1="1";
Console.WriteLine(" Torre de Hanoi ");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine(" | | |");
Console.WriteLine(" " + d1 + " |" + " |");
Console.WriteLine(" " + d2 + " |" + " |");
Console.WriteLine(" " + d3 + " |" + " |");
Console.WriteLine("------A------B------C------");
Console.WriteLine("");
Console.WriteLine("Empieza el juego");
Console.WriteLine("1");
Console.WriteLine(" | | |");
Console.WriteLine(" | |" + " |");
Console.WriteLine(" " + d2 + " |" + " |");
Console.WriteLine(" " + d3 + " |" + " "+ d1);
Console.WriteLine("------A------B------C------");
Console.WriteLine("");
Console.WriteLine("2");
Console.WriteLine(" | | |");
Console.WriteLine(" | |" + " |");
Console.WriteLine(" | |" + " |");
Console.WriteLine(" " + d3 + " " +d2+ " " + d1);
Console.WriteLine("------A------B------C------");
Console.WriteLine("");
Console.WriteLine("3");
Console.WriteLine(" | | |");
Console.WriteLine(" | |" + " |");
Console.WriteLine(" | "+ d1 + " |");
Console.WriteLine(" " + d3 + " " + d2 + " |");
Console.WriteLine("------A------B------C------");
Console.WriteLine("");
Console.WriteLine("4");
Console.WriteLine(" | | |");
Console.WriteLine(" | | |");
Console.WriteLine(" | " + d1 + " |");
Console.WriteLine(" | "+ d2 + " "+ d3);
Console.WriteLine("------A------B------C------");
Console.WriteLine("");
Console.WriteLine("5");
Console.WriteLine(" | | |");
Console.WriteLine(" | | |");
Console.WriteLine(" | | |");
Console.WriteLine(" " + d1 + " " + d2 + " " + d3);
Console.WriteLine("------A------B------C------");
Console.WriteLine("");
Console.WriteLine("6");
Console.WriteLine(" | | |");
Console.WriteLine(" | | |");
Console.WriteLine(" | | "+ d2);
Console.WriteLine(" " + d1 + " | " + d3);
Console.WriteLine("------A------B------C------");
Console.WriteLine("");
Console.WriteLine("7");
Console.WriteLine(" | | |");
Console.WriteLine(" | | " + d1);
Console.WriteLine(" | | " + d2);
Console.WriteLine(" | | " + d3);
Console.WriteLine("------A------B------C------");
Console.WriteLine("");
Console.WriteLine("Fin del juego");
Console.WriteLine();
Console.ReadKey();
}
}
}