当前位置:网站首页>Yyds dry goods inventory C language recursive implementation of Hanoi Tower
Yyds dry goods inventory C language recursive implementation of Hanoi Tower
2022-07-06 21:51:00 【ZS_ Jie】
The tower of Hanoi problem refers to : There are three needles on one board A、B、C.A The needle is covered with a needle 64 A disc of different sizes , According to the big one 、 The small ones are arranged in the order of , I want to put this 64 A disk from A The needle moves to C On the needle , Only one disc can be moved at a time , The movement process can be done with the help of B The needle . But at any time , Any disc on the needle must keep the big one down , Small in . Enter the number of disks to be moved from the keyboard , Give the process of moving .
Ideas :
- n==1 when , When only one disc is moved , Direct the disc from A The needle moves to C The needle
- n>1 when ,
hold (n-1) A disk from A The needle moves to B The needle ( With the help of C The needle );
A The last disc on the needle moves to C The needle ;
B On the needle (n-1) A disk moves to C The needle ( With the help of A The needle ).
Every time I do it , One less moving disc , Gradually decreasing , Finally, when n by 1 when , Complete the entire movement
Algorithm implementation
example
When there is 3 When you have a plate
边栏推荐
- [Yu Yue education] reference materials for surgical skills teaching in Tongji University
- In JS, string and array are converted to each other (I) -- the method of converting string into array
- 一行代码可以做些什么?
- 互联网快讯:吉利正式收购魅族;胰岛素集采在31省全面落地
- Fzu 1686 dragon mystery repeated coverage
- PostgreSQL 修改数据库用户的密码
- [Chongqing Guangdong education] Tianjin urban construction university concrete structure design principle a reference
- Checkpoint of RDD in spark
- Efficiency tool +wps check box shows the solution to the sun problem
- Sequoia China, just raised $9billion
猜你喜欢
Reptile practice (V): climbing watercress top250
【力扣刷题】32. 最长有效括号
1292_ Implementation analysis of vtask resume() and xtask resume fromisr() in freeros
[Chongqing Guangdong education] Information Literacy of Sichuan Normal University: a new engine for efficiency improvement and lifelong learning reference materials
[Li Kou brush questions] 32 Longest valid bracket
Absolute primes (C language)
Five wars of Chinese Baijiu
50 commonly used numpy function explanations, parameters and usage examples
美国科技行业结束黄金时代,芯片求售、裁员3万等哀声不断
The difference between break and continue in the for loop -- break completely end the loop & continue terminate this loop
随机推荐
WEB功能测试说明
快讯:飞书玩家大会线上举行;微信支付推出“教培服务工具箱”
Five wars of Chinese Baijiu
缓存更新策略概览(Caching Strategies Overview)
JS according to the Chinese Alphabet (province) or according to the English alphabet - Za sort &az sort
Absolute primes (C language)
基于InsightFace的高精度人脸识别,可直接对标虹软
Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic
JS method to stop foreach
技术分享 | 抓包分析 TCP 协议
Fzu 1686 dragon mystery repeated coverage
JS operation DOM element (I) -- six ways to obtain DOM nodes
美国科技行业结束黄金时代,芯片求售、裁员3万等哀声不断
互联网快讯:吉利正式收购魅族;胰岛素集采在31省全面落地
PostgreSQL modifies the password of the database user
Vim 基本配置和经常使用的命令
【力扣刷题】32. 最长有效括号
MySQL removes duplicates according to two fields
bat脚本学习(一)
Guava: use of multiset