Advertisement
catalyn

turnurile din hanoi

Oct 8th, 2015
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. #include <stdio.h>
  5.  
  6. void move(int n, int sursa, int destinatie, int intermediar) {
  7. if (n == 1) {
  8.  
  9. return;
  10. }
  11. move(n - 1, sursa, intermediar, destinatie);
  12.  
  13. move(n - 1, intermediar, destinatie, sursa);
  14. }
  15.  
  16. int main() {
  17. int n;
  18.  
  19. move(n, 1, 2, 3); // muta discurile de pe tija 1 pe 2 folosind intermediar tija 3
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement