Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. void Hanoi(Stack<int> source, Stack<int> dest, Stack<int> temp,int N)
  2. {
  3. if (N > 0) {
  4.  
  5. //move N-1 from source -> temp
  6. Hanoi(source, temp, dest, N - 1);
  7.  
  8. //move bottom from source -> dest
  9. var data = source.Pop();
  10. dest.Push(data);
  11.  
  12. //move N-1 from temp->dest
  13. Hanoi(temp, dest,source,N - 1);
  14.  
  15. }
  16. Print(source, dest, temp);
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement