~cpp
#include <iostream>
using namespace std;
int Mcount = 0; //기
int hanoi(int disk,int start, int other, int finish){
Mcount++; // 1
// 거 1 start 기 finish 기
if(disk == 1)
cout << start << " " << finish << endl;
// 갯 1
else
{
hanoi(disk-1,start,finish,other); // other 기 기
cout << start << " " << finish << endl;
hanoi(disk-1,other,start,finish); // other 기 finish 기 기
}
return Mcount;
}
void main(){
int disk,MoveCount;
cout << " 갯 : ";
cin >> disk;
MoveCount = hanoi(disk,1,2,3);
cout << endl << " " << MoveCount << endl;
}