|
#include<stdio.h>
int move(int n, char a, char b, char c){
if(n==1)
printf("move disk from %c to %c \n", a, c);
else{
move(n-1, a, c, b);
move(1, a, b, c);
move(n-1, b, a, c);
} hanoi.cpp 295바이트
|
- 페이지 1페이지
- 가격 700원
- 등록일 2011.11.20
- 파일종류 기타
- 참고문헌 없음
- 최근 2주 판매 이력 없음
|
|
* 하노이 탑의 규칙은 *
* n개의 원판이 A에 있다면 *
* 상위 n-1개의 원판을 B로 옮기고 *
* 마지막 n번째 원판을 C로 옮긴 후 *
* B로 옮긴 n-1개의 원판을 다시 C로 옮긴는 것이다. *
*
|
- 페이지 1페이지
- 가격 1,000원
- 등록일 2008.08.14
- 파일종류 기타
- 참고문헌 없음
- 최근 2주 판매 이력 없음
|
|
컴파일과 실행을 하면 결과는 다음과 같습니다.
C:\test>javac TowerOfHanoi.java
C:\test>java TowerOfHanoi
Move from Src to Aux.
Move from Src to Dst.
Move from Aux to Dst.
Move from Src to Aux.
Move from Dst to Src.
Move from Dst to Aux.
Move from Src to Aux.
Move from Src to Dst.
|
- 페이지 1페이지
- 가격 800원
- 등록일 2006.04.12
- 파일종류 기타
- 참고문헌 없음
- 최근 2주 판매 이력 없음
|