몇시간 종이에 적으면서 고민하다가 결국 풀었음
문제푸는게 참 성취감이 있네 ㄷㄷ
void hanoiTower(int disks, int presentPlace, int temporaryPlace, int targetPlace) {
if (disks == 2) {
cout << presentPlace << " → " << temporaryPlace << endl;
cout << presentPlace << " → " << targetPlace << endl;
cout << temporaryPlace << " → " << targetPlace << endl;
}
if (disks > 2) {
hanoiTower(disks - 1, presentPlace, targetPlace, temporaryPlace);
cout << presentPlace << " → " << targetPlace << endl;
hanoiTower(disks - 1, temporaryPlace, presentPlace, targetPlace);
}
}
ㅊㅊ
해당 댓글은 삭제되었습니다.
댓글 제한때문에 안달려서 본문에 추가했슴
잘했으여
ㅊㅊ
코린이라 하지마라 코틀린 잼틀린 말하는거랑 헷갈림 - dc App
진자성취감지리겠다