본문 바로가기

이곳저곳 관심이 많아요

검색하기
이곳저곳 관심이 많아요
프로필사진 킹수맨

  • 분류 전체보기 (10)
    • Programming (7)
      • Algorithm (1)
      • Android (5)
      • Data structure (1)
    • 취미 (1)
      • 운동 (1)
      • 독서 (0)
Guestbook
Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
일 월 화 수 목 금 토
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Tags
  • 재귀
  • 자료구조
  • 안드로이드
  • 하노이탑
  • 브루트포스 알고리즘
  • 구현
  • 구데기컵
  • 순환
more
Archives
Today
Total
관리 메뉴
  • 글쓰기
  • 방명록
  • RSS
  • 관리

목록자료구조 (1)

이곳저곳 관심이 많아요

2장. 순환/하노이탑

#include //막대 from에 쌓여있는 n개의 원판을 막대 tmp를 사용해 to로 옮긴다. void hanoi_tower(int n,char from, char tmp, char to) { if (n == 1) { printf("원판 1을 %c에서 %c로 옮긴다.\n",from,to); } else { hanoi_tower(n - 1, from, to, tmp); printf("원판 %d를 %c에서 %c로 옮긴다.\n", n, from, to); hanoi_tower(n - 1, tmp, from, to); } } int main(void) { hanoi_tower(4, 'A', 'B', 'C'); }

Programming/Data structure 2021. 3. 18. 22:42
Prev 1 Next

Blog is powered by kakao / Designed by Tistory

티스토리툴바