~cpp 
#include <iostream>
using namespace std;
void hanoi (int n, int start, int finish, int extra);
int main() 
{
	int n;
	cout << "디스크의 수를 입력하세요: ";
	cin >> n;
	hanoi(n,1,2,3);
	return 0;
}
void hanoi (int n, int start, int finish, int extra) 
{
	if (n!=0)
	{
		hanoi ( n-1, start, extra, finish );
		cout << n << "디스크를 " << start << " 기둥 으로부터 " << finish << " 기둥으로 옮긴다.\n";
		hanoi(n-1, extra, finish, start);
	}
}
Retrieved from http://wiki.zeropage.org/wiki.php/HanoiProblem/재동
last modified 2021-02-07 05:23:21