0
I will the mathematics code and the recursive code for towers of Hanoi in c#
i need help plz
1 Respuesta
0
class SomeClass
{
static void put(char from, char to)
{
Console.WriteLine("From " + from + " to " + to);
}
static void Hanoi(int n, char A = 'A', char B = 'B', char C = 'C')
{
if(n==1)
{
put(A, C);
}else
{
Hanoi(n - 1, A, C, B);
put(A, C);
Hanoi(n - 1, B, A, C);
}
}
static void Main(string[] args)
{
Hanoi(2);
Console.ReadKey();
}
}