标签:font 有趣的 pre size erro static bsp out system
1、public static String exR1(int n){
if(n<=0) return "";
return exR1(n-3)+ n + exR1(n-2) + n;
}
System.out.println(exR1(6)); //311361142246
2、public static String exR2(int n){ String s = exR1(n-3)+ n + exR1(n-2) + n;
if(n<=0) return "";
return s;
}
··注:
这段代码的基础情况永远不会被访问,会循环往复直到发生
StackOverflowError.
3、public static int mystery(int a,int b){
if(b == 0) return 0;
if(b % 2 == 0) return mystery(a+a, b/2);
return mystery(a+a, b/2)+a;
}
标签:font 有趣的 pre size erro static bsp out system
原文地址:http://www.cnblogs.com/zhanxiage/p/7613022.html