Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. int main(){
  5.     int n;
  6.     printf("inserisci N\n");
  7.     scanf("%d", &n);
  8.     hanoi(n, 'A', 'C', 'B');
  9. }
  10.  
  11. int hanoi(int n, char a, char c, char b){
  12.     if (n==1){
  13.         printf("%d) sposta da %c a %c \n",i, a, c);
  14.     }else{
  15.         hanoi(n-1, a, b, c);
  16.         hanoi(1, a, c, b);
  17.         hanoi (n-1, b, c, a);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement