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;
public class BinaryTree {
private Node root;
// 添加数据
public void add(int data) {
// 递归调用
if (null == root)
root = new Node(data, null, null);
else
addTree(root, data);
......
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 game;
public class Money {
public static void main(String[] args) {
fun("", 10);
System.out.println("总共算法:" + i);
}
// 10元钱的组成,1,2,5任意组合
public static int i = 1;
public static void fun(String log, int n) {
......
JAVA RMI 快速入门实例
本实例为参考多篇文章写就而成,网上及书上各类文章介绍如何使用RMI有多种实例可参考,譬如有:
1. 用命令rmiregistry启动RMI注册服务的
2. 同时创建存根(stub)和骨架(skeleton)的
3. 只创建存根类的的(jdk1.2以后版本)
4. 通过RemoteRef和rmi://协议字串方式的
5. 比较少讲到的用LocateRegist ......