本题是用JavaScript在网页上打印金字塔
每层中星星的数量=当前层数*2-1
每层星星前的空格=金字塔层数-当前层数
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf8"/>
</head>
<body>
</body>
</html>
<script>
var i,num,k;
num = prompt("请输入金字塔的行数");
for(i=1;i<=num;i++){
for(k=1;k<=num-i;k++)
document.write(" ");
for(j=0;j<2*i-1;j++)
document.write("*");
document.write("<br>");
}
</script>