易截截图软件、单文件、免安装、纯绿色、仅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中集合容器类List和Set的用法

List的用法
List包括List接口以及List接口的所有实现类。因为List接口实现了Collection接口,所以List接口拥有Collection接口提供的所有常用方法,又因为List是列表类型,所以List接口还提供了一些适合于自身的常用方法,如表1所示。
表1  List接口定义的常用方法及功能
从表1可以看出,List接口提供的适合于自身的 ......

java:手写MyArrayLisy的常用方法,增删改查

package arrays.myArray;
public class MyArrayList {
 private Object[] arrObj = new Object[3];
 private int size = 0;
 
 // 长度
 public int size() {
  return size;
 }
 // insert
 public void add(Object obj) {
  add(size,obj);
&nb ......

java:三种经典大排序汇总,冒泡,插入,选择

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 };
 & ......

java:Student类

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