你的位置:首页 > Java教程

[Java教程]打印菱形


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>打印菱形</title>
</head>
<body>
<center>
<script language="javascript">
var k=prompt("请输入打印行数:","");
for(var i=1;i<=k;i++){
for(var j=0;j<i;j++){
document.write("*&nbsp;&nbsp;&nbsp;");
}
document.write("<br/>");

}
for(var i=k-1;i>0;i--){
for(var j=0;j<i;j++){
document.write("*&nbsp;&nbsp;&nbsp;");
}
document.write("<br/>");

}
</script>
</center>
</body>
</html>