검색어 입력폼

[자료구조론] - C언어 Towers of Hanoi

저작시기 2013.07 |등록일 2014.05.06 한글파일한컴오피스 (hwp) | 8페이지 | 가격 800원

소개글

자료구조론

목차

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);

참고 자료

없음
다운로드 맨위로