java:递归汉罗塔游戏最少的走法
package game;
public class HanTaGame {
public static void main(String[] args) {
fun('1', '2', '3', 2);
}
// 汉塔游戏解决方案
public static void fun(char src, char idle, char dest, int n) {
if (1 == n) {
System.out.println(src + "--->" + dest);
return;
}
//定义一个顺序
fun(src, dest, idle, n - 1);
System.out.println(src + "--->" + dest);
//进行顺序的交换
fun(idle, src, dest, n - 1);
}
}
相关文档:
package arrays.myArray;
import java.util.Scanner;
public class SortObject {
private static int intercePosition = 0; // 记录单个运算数据的长度
private static int[] intercePositionIndex = null; // 记录“(”的下标
private static int[] intercePositionEnd = null; // 记录 ......
package collection;
import java.util.*;
public class NewSet {
public static void main(String[] args) {
Set<Student> students = new HashSet<Student>();
for (int i = 0; i < 6; i++) {
students.add(new Student("Happy"+i,"male"+i,20+i)) ......
package collection;
public class Student {
public Student() {}
public Student(String name, String sex, int age) {
this.name = name;
this.sex = sex;
this.age = age;
}
@Override
public String toString() {
......
package game;
public class HanTa {
public static int i = 0;
public static void main(String[] args){
calc('A', 'B', 'C', 2);
System.out.println("最少需要"+i+"步。");
}
//汉罗塔游戏计算
public static void calc(char src, char ilde, c ......
JAVA RMI 快速入门实例
本实例为参考多篇文章写就而成,网上及书上各类文章介绍如何使用RMI有多种实例可参考,譬如有:
1. 用命令rmiregistry启动RMI注册服务的
2. 同时创建存根(stub)和骨架(skeleton)的
3. 只创建存根类的的(jdk1.2以后版本)
4. 通过RemoteRef和rmi://协议字串方式的
5. 比较少讲到的用LocateRegist ......