티스토리 뷰

#include <stdio.h>


void HanoiTowerMove(int num, char from, char by, char to){

if(num == 1){

printf("1 : %c -> %c\n", from, to);

}

else{

HanoiTowerMove(num - 1, from, to, by);

printf("%d : %c -> %c\n", num, from, to);

HanoiTowerMove(num - 1, by, from, to);

}

}


int main(){

int num = 0;

scanf("%d", &num);

HanoiTowerMove(num, 'A', 'B', 'C');

return 0;

}

댓글
댓글쓰기 폼