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

📄 hanoi.cpp

📁 数据结构与程序设计教材源码 数据结构与程序设计教材源码
💻 CPP
字号:
 
#include   <iostream.h>
 
const int disks = 6;  // Make this constant much smaller to run program.
void move(int count, int start, int finish, int temp);
 
/* 
 
Pre:  None.
Post: The simulation of the Towers of Hanoi has terminated.
 */

main()
{
   move(disks, 1, 3, 2);
}
 
void move(int count, int start, int finish, int temp)
{
   if (count > 0) {
      move(count - 1, start, temp, finish);
      cout << "Move disk " << count << " from " << start
           << " to " << finish << "." << endl;
      move(count - 1, temp, finish, start);
   }
}

⌨️ 快捷键说明

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