当前位置:网站首页>分而治之之经典Hanoi
分而治之之经典Hanoi
2022-06-28 09:06:00 【C_x_330】
package com.Cx_330.Algorithm.Hanoi;
public class HanoiDemo {
public static void main(String[] args) {
char first='A';
char second='B';
char third='C';
playHanoi(first,second,third,7);
}
private static void playHanoi(char destination, char mid, char resource, int i) {
if(i==1){
System.out.println("第 1 个盘子从 "+destination+" 移动到 "+resource);
}else {
playHanoi(destination,resource,mid,i-1);
System.out.println("第 "+i+" 个盘子从 "+destination+" 移动到 "+resource);
playHanoi(mid,destination,resource,i-1);
}
}
}
边栏推荐
- 图解MySQL的binlog、redo log和undo log
- How to solve the problem of port number occupation
- spark的资源调度和任务调度
- Almost union find (weighted union search)
- SQL 優化經曆:從 30248秒到 0.001秒的經曆
- STL -- binder
- Test cases for learning the basic content of software testing (II)
- 用Pytorch搭建第一个神经网络且进行优化
- Rman Backup Report Ora - 19809 Ora - 19804
- Construire le premier réseau neuronal avec pytorch et optimiser
猜你喜欢

Application of current limiting protector in preventing electrical fire in shopping malls

"Jianzhi offer" -- Interview Question 4: finding two-dimensional arrays
![[cloud native | kubernetes] in depth understanding of pod (VI)](/img/ae/f16f5c090251ab603b88ddadff7eb3.png)
[cloud native | kubernetes] in depth understanding of pod (VI)

Expérience d'optimisation SQL: de 30248 secondes à 0001 secondes

Stock suspension

Superimposed ladder diagram and line diagram and merged line diagram and needle diagram

Valentine's Day - VBS learning (sentences, love words)
![[untitled]](/img/bb/213f213c695795daecb81a4cf2adcd.jpg)
[untitled]

Discussion on safety management of centralized maintenance construction site of substation under the mode of operation and maintenance

股票 停牌
随机推荐
Large current and frequency range that can be measured by Rogowski coil
Where is CentOS mysql5.5 configuration file
Discussion on safety management of centralized maintenance construction site of substation under the mode of operation and maintenance
Is it safe for Huatai Securities to open an account online? What is the handling process
Apiccloud, together with 360 Tianyu, helps enterprises keep the "first pass" of APP security
Why does select * lead to low query efficiency?
批量修改表和表中字段排序规则
Application of current limiting protector in preventing electrical fire in shopping malls
罗氏线圈可以测量的大电流和频率范围
DEJA_VU3D - Cesium功能集 之 052-模拟卫星轨道(高空)效果
Chrome devtools
Basic operation of PMP from applying for the exam to obtaining the certificate, a must see for understanding PMP
Not so Mobile
Error: `brew cask` is no longer a `brew` command. Use `brew <command> --cask` instead.
Calculation of stock purchase and sale expenses
硬盘基本知识(磁头、磁道、扇区、柱面)
SQL 優化經曆:從 30248秒到 0.001秒的經曆
[.Net6] GRP server and client development cases, as well as the access efficiency duel between the minimum API service, GRP service and traditional webapi service
中金财富开户安全吗?怎么收费?
Find the total number of 1 appearing in the integer 1-N and the number of 1 in the binary of the integer