zxy0307's picture
Upload 2300 files
0284885 verified
Raw History Blame Contribute Delete
563 Bytes
package Case4_package;
public class Test {
public static void main(String[] args) {
/*
可爱的小明特别喜欢爬楼梯,他有时候一次爬一个台阶,有时候一次爬两个台阶。
如果这个楼梯有100个台阶,小明一共有多少种爬法?
*/
System.out.println(getCount(20));
}
public static int getCount(int n) {
if (n == 1) {
return 1;
}
if (n == 2) {
return 2;
}
return getCount(n - 1) + getCount(n - 2);
}
}