⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 8.9.cpp

📁 c入门代码大全
💻 CPP
字号:
//hanoi塔问题
#include<stdio.h> 
void main()
{
    void hanoi(int n,char one,char two,char three);
    int m;
    printf("input the number of dishes: ");
    scanf("%d",&m);
    printf("the step to move %d diskes:\n",m);
    hanoi(m,'A','B','C');
    getchar();
    getchar();
}
void hanoi(int n,char one,char two,char three)
{
     void move(char x,char y);
     if(n==1)
       move(one,three);
     else
       {
          hanoi(n-1,one,three,two);
          move(one,three);
          hanoi(n-1,two,one,three);
       }
}
void move(char x,char y)
{
     printf("%c-->%c\n",x,y);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -