[자료구조론] - C언어 Towers of Hanoi
- 최초 등록일
- 2014.05.06
- 최종 저작일
- 2013.07
- 8페이지/ 한컴오피스
- 가격 1,000원
소개글
자료구조론
목차
1. Towers of Hanoi
1) Program source code
2) Program build output
3) Program execution(screen shot)
4) Program usage
5) comment
2. Show that the following statements are incorrect
3. 문자열 삭제 프로그램
1) Program source code
2) Program build output
3) Program execution(screen shot)
4) Program usage
5) comment
본문내용
1. Towers of Hanoi
(1) Program Source Code
#include <stdio.h>
int moveCount = 0;
int funcCallCount = 0;
void move(int n, int from, int to);
void hanoi_recursion(int depth, int n, int from, int by, int to);
void hanoi_recursion(int depth, int n, int from, int by, int to) {
funcCallCount++;
if(n==1){
move(n, from, to);
return
}
hanoi_recursion(depth+1, n-1, from, to, by);
move(n, from, to);
hanoi_recursion(depth+1, n-1, by, from, to);
}
void move(int n, int from, int to) {
moveCount++;
printf("%5d/ %d %d %d\n",
moveCount, n, from, to);
참고 자료
없음