Blogger Information
Blog 10
fans 0
comment 2
visits 7862
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
javascript循环使用 五期线上班
阿坚的博客
Original
645 people have browsed it

1:while 实现99乘法表表

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<script type="text/javascript">
		var i=1;
		
		while(i<10 ){
			var j=i;
			while(j<10){
				var kong="   "
				if (i*j<10) {
					kong+="  ";
				}
				document.write(i+'x'+j+'='+(i*j)+kong);
				j++;
			}
			document.write('<br>');
			i++;
		}
		document.write('<hr>');
	</script>
</body>
</html>

运行实例 »

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

2:循环输出倒三角

里面有用了2中方法输出 ,一种我注释了。

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<script type="text/javascript">
 	//用循环写出倒三角
 	var xin='Δ';
 	document.write("   ");
 	for(var i=0;i<11;i++){
		for (var j=i; j < 10; j++) {
			// switch(i)
			// 	{
			// 	case 1:
			// 	  kong=" "
			// 	  break;
			// 	case 2:
			// 	  kong="  "
			// 	  break;
			// 	case 3:
			// 	  kong="   "
			// 	  break;
			// 	case 4:
			// 	  kong="    "
			// 	  break;
			// 	case 5:
			// 	  kong="     "
			// 	  break;
			// 	case 6:
			// 	  kong="      "
			// 	  break;
			// 	case 7:
			// 	  kong="       "
			// 	  break;
			// 	case 8:
			// 	  kong="        "
			// 	  break;
			// 	case 9:
			// 	  kong="         "
			// 	  break;
			// 	}
			document.write(xin);
		}
			kong+=" ";
		document.write(xin+"<br>"+kong);
	</script>
</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