易截截图软件、单文件、免安装、纯绿色、仅160KB

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);
 }
}


相关文档:

Java 线程编程中的同步、重复、定时

(一)线程同步
实现生产者消费者问题来说明线程问题,举例如下所示:
/**
* 生产者消费者问题
*/
public class ProducerConsumer {

/**
* 主方法
*/
public static void main(String[] args) {
ProductBox pb = new ProductBox ......

java:double类型截取俩位小数,不取舍,

public class Split{
 public static void main(String[] args){
       double pai = 3.14159;
        findTwo(pai);
  public static void findTwo(double value){
    System.out.println(new DecimalFormat("0.##"). ......

java:手写二叉树BinaryTree添加和查询方法

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);
......

java:ArrayList循环遍历的俩种方法使用

package collection;
import java.util.*;
public class NewArrayList {
 public static void main(String[] args) {
  List<Student> students = new ArrayList<Student>();
  for (int i = 0; i < 6; i++) {
   students.add(new Student("Happy"+i,"male" ......

java:Set循环遍历的俩种方法使用

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)) ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号