Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Hanoi(Stack<int> source, Stack<int> dest, Stack<int> temp,int N)
- {
- if (N > 0) {
- //move N-1 from source -> temp
- Hanoi(source, temp, dest, N - 1);
- //move bottom from source -> dest
- var data = source.Pop();
- dest.Push(data);
- //move N-1 from temp->dest
- Hanoi(temp, dest,source,N - 1);
- }
- Print(source, dest, temp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement