java:递归:上楼梯每次只能一步或者两步,有多少走法
package floatt;
public class Go {
public static int i = 0;
public static void main(String[] args){
calc("", 5);
System.out.println("总共有"+i+"种走法~");
}
//上楼梯每次只需一步或者两步,有多少走法
public static void calc(String log, int num){
if (num == 0) {
i++;
System.out.println(log.substring(0,log.length()-1));
return;
}else if(num == 1) {
i++;
System.out.println(log+"1");
return;
}
calc(log+"1,", num - 1);
calc(log+"2,", num - 2);
}
}
相关文档:
再次从网上查询,搜到了RXTXcomm.jar包比较好,是封装了comm.jar的方法。
安装:
1.copy rxtxSerial.dll to [JDK-directory]\jre\bin\rxtxSerial.dll
2.copy RXTXcomm.jar to [JDK-directory]\jre\lib\ext\RXTXcomm.jar
&nbs ......
鉴于网上搜到的都是基于jdk1.4或以前版本,而且本地库用的是C语言。而现在是基于C++,所以更新记录如下:
第一步:创建Java源码文件
public class Hello{
static{
System.loa ......
(一)线程同步
实现生产者消费者问题来说明线程问题,举例如下所示:
/**
* 生产者消费者问题
*/
public class ProducerConsumer {
/**
* 主方法
*/
public static void main(String[] args) {
ProductBox pb = new ProductBox ......
package arrays.myArray;
public class MyLinkedList {
private int size = 0;
private Node1 head = null;
// 添加
public void add(Object obj) {
add(size, obj);
}
// 修改
public void add(int index, Object obj) {
if (null == head) ......
package arrays.myArray;
public class SortArr {
public static void main(String[] args) {
int[] arrInt = { 4, 7, 8, 5, 6, 3, 2, 3, 4 };
maoPaoSort(arrInt);
print("冒泡排序:", arrInt);
arrInt = new int[]{ 4, 7, 8, 5, 6, 3, 2, 3, 4 };
& ......