您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

java简单卡特兰数代码示例

2026/2/4 11:41:13发布13次查看
<span style="font-size:24px;">package 卡特兰数; public class catalan { public static void main(string[] args) { int n = 3; system.out.println(catalanprocess(n)); } private static int catalanprocess(int n) { if(n <= 1){ return 1; } int[] h = new int[n+1]; int result = 0; h[0] = h[1] = 1; for(int i=2 ; i<=n ; i++){ h[i] = 0; for(int j=0 ; j<i ; j++){ h[i] += (h[j]*h[i-(j+1)]); } } result = h[n]; return result; } }</span>
以上就是java简单卡特兰数代码示例的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product