首页 > 代码库 > 不使用递归法求值

不使用递归法求值

<script type="text/javascript">//f(m,n)={n,(m=1) ||m,(n=1)||f(m-1,n)+f(m,n-1)(m>1,n>1)}function aaa(m,n){var arr=[];var arrshu=[];var minarr=[];arr.push([m,n]);arrshu.push(1);for(var i=m;i>0;i--) {if (i == m) {for (var j = n - 1; j > 0; j--) {arr.push([i, j]);arrshu.push(1);  }  } else {for (var k = n; k > 0; k--) {var a = [i + 1, k];var c = [i, k + 1];var count1 = 0;for (var b = 0; b < arr.length; b++) {var flag1 = 0, flag2 = 0;for (var f = 0; f < arr[b].length; f++) {if (arr[b][f] == c[f]) {  ++flag1;if(([i, k][f]==1)&&c[f]==1){  --flag1;  }if(flag1==2){count1 += arrshu[b]  }  }if (arr[b][f] == a[f]) {  ++flag2;if(([i, k][f]==1)&&a[f]==1){  --flag2;  }if(flag2==2){count1 += arrshu[b]  }  }  }  }arr.push([i, k]);arrshu.push(count1);  }  }  }return {arr:arr,arrshu:arrshu}  }  window.onload=function() {aaa(4, 3)  console.log(aaa(4, 3))// console.log([1,2,3] in[[1,2,3],[1,2]])}</script>

不使用递归法求值