批改状态:未批改
老师批语:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
/*【案例1】js打印九九乘法表
【案例2】计算:用*号在页面中输出一个三角形(while)
*/
//用for循环实现九九乘法表
/*var i=1;
for(i;i<=10;i++){
document.write(i);
}*/
/*for(i=1;i<=9;i++){
for(j=1;j<=i;j++){
document.write(j+'*'+i+' ');
}
document.write("<br/>");
}*/
//用while循环实现九九乘法表
/*var a=0;
while(a<9){
a++;
var b=0;
while(b<a){ //1 2
b++;
document.write(b+'*'+a+' '); //1*1
}
document.write('<br/>');
}*/
//2.用*号在页面中输出一个三角形(while)
/*for(var h=0;h<9;h++){
for(w=0;w<=h;w++){
document.write('*');
}
document.write('<br/>');
}*/
var h=0;
while(h<=9){
h++;
var w=0;
while(w<h){
w++;
document.write('*');
}
document.write('<br/>');
}
</script>
</body>
</html>点击 "运行实例" 按钮查看在线实例
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号