SHARE
TWEET

Untitled

a guest Feb 27th, 2020 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. void hanoi(int n, char da, char appoggio, char arrivo);
  3. int main() {
  4.     int i,j;
  5.     char a,b,c;
  6.     hanoi(4, 'A', 'B', 'C');
  7. }
  8. void hanoi(int n, char da, char appoggio, char arrivo){
  9.     if(n==1){
  10.        printf("%c-%c",da,arrivo);
  11.     }
  12.     else{
  13.        hanoi(n-1, da, arrivo, appoggio);
  14.        printf("\n");
  15.        printf("%c-%c\n",da, arrivo);
  16.        hanoi(n-1, appoggio, da, arrivo);
  17.     }
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top