var a= Array(5);for ( var i= 0;i<a.length;i++){ a[i]=Array(i+1); a[i][0]=1; for(var j=0;j<a[i].length;j++) { if(i==j) { a[i][j]=1 } else{ if((i-1)>=0&&(j-1)>=0) { a[i][j]=a[i-1][j-1]+a[i-1][j];} } } }; for(var i in a){ for(var j in a[i]) { document.write(a[i][j]); } document.write("<br>");}
时间: 2024-10-06 04:55:46