티스토리 뷰
반응형
#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;
}
'C, C++ > 데이터구조 & 자료구조' 카테고리의 다른 글
C언어 선택 정렬(Selection sort) (0) | 2016.06.06 |
---|---|
C언어 버블정렬 알고리즘(Bubble sorting algorithm) (0) | 2016.06.06 |
C언어 재귀(Recursive) 피보나치 수열 (0) | 2016.06.06 |
C언어 재귀이용 피보나치(Fibonacci) 수열 (0) | 2016.06.06 |
C언어 재귀 팩토리얼(Factorial) 예제 (0) | 2016.06.06 |
댓글
티스토리 방명록
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
Blog is powered by
Tistory / Designed by
Tistory
Contact: j0n9m1n1@gmail.com
Contact: j0n9m1n1@gmail.com