~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; }