javascript打印完整金字塔型_完整菱形_空心菱形_思路算法详解_js源代码:
http://blog.csdn.net/wenximalong/article/details/8224891#
<script type="text/javascript">
for (var i = 0; i <= 5; i++) { //外循环控制行数
for (var k = 5; k > i ; k--) {
document.write(" ");
// document.write("n");
}
for (var j = 0; j < 2*i-1; j++) {
document.write("*");
}
document.write("<br/>");
}
for (var a = 4; a >= 1; a--) { //行数递减
for (var b = 0; b <= 4-a; b++) {
document.write(" ");
// document.write("n");
}
for (var c = 2*a-1; c >= 1 ; c--) {
document.write("*");
}
document.write("<br/>");
}
</script>