Blogger Information
Blog 10
fans 0
comment 0
visits 6384
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
菱形的案例
俞斌的博客
Original
683 people have browsed it

实例

<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title>for循环 菱形案例</title>
	<script type="text/javascript">
	var n = parseInt(prompt("请输入菱形的层数一半"));
		for (var i = 1; i <= n; i++) 
		{
			for (var k = 1 ;k <= n - i;k++) 
			{
				document.write("  ");
			};
			for (var j = 1; j <= 2 * i - 1; j++) 
			{
				document.write("△");
			};
			document.write("<br>");
		};
		for (var x = 1;x <= n - 1;x++) 
		{
			for (var y = 1;y <= x;y++) 
			{
				document.write("  ");
			};
			for (var z = 2 * (n - x) - 1; z >= 1; z--) 
			{
				document.write("▽");
			};
			document.write("<br>");
		};
	</script>
</head>
<body>

</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Correction status:Uncorrected

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post