<!DOCTYPE html><html leng = \'en\'><head><meta charset = \'UTF-8\'/></head><body><script>var arr = [[],[],[],[],[],[],[],[],[],[]]for(var i = 0; i < 10; i++){for(var j = 0; j < i + 1; j++){if(j === 0 || j === i){arr[i][j] = 1;}else{arr[i][j] = arr[i - 1][j - 1] + arr[i - 1][j];}}}console.log(arr);</script></body></html>
js写杨辉三角形(二维数组)
未经允许不得转载:爱站程序员基地 » js写杨辉三角形(二维数组)