0

I will the mathematics code and the recursive code for towers of Hanoi in c#

i need help plz

6th Dec 2016, 1:07 PM
Kalenga Leader
Kalenga Leader - avatar
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(); } }
7th Dec 2016, 9:28 PM
Maciej Falbogowski
Maciej Falbogowski - avatar