JSS作业:
1:
<script>
var cnt = parseInt(window.prompt("请输入打印的行数:"));
for (var i = 1; i <= cnt; i++){
for (var j = 1; j <= i; j++){
document.write("*")
}
document.write("<br>")
}
</script>
2:
<script>
let cnt = parseInt(prompt("请输入要打印的行数:"));
for(var i=1;i<=cnt;i++){
for(var j=1;j<=cnt-i;j++){
document.write(" ");
}
for(var j=1;j<=2*i-1;j++){
document.write("*");
}
document.write("<br/>");
}
</script>
3:
<script>
let cnt = parseInt(prompt("请输入要打印的行数:"));
for(var i=0; i<cnt; i++){
for(var j=cnt; j>i; j--){
document.write(" ");
}
for(var k=0;k<2*i+1;k++){
document.write("*");
}
document.write("</br>");
}
for(var i=cnt-1; i>0; i--){
for(var j=cnt; j>=i; j--){
document.write(" ");
}
for(var k=0; k<2*i-1; k++){
document.write("*");
}
document.write("</br>")
}
</script>
4:
<script>
var num=0;
for(var i=1; i<10; i++){
for(var j=1; j<10; j++){
num = i * j;
if(num / 10 < 1){
num=" " + i * j;
}
if(j<=i) {
document.write(j + "*" + i + "=" + num + " ");
}
}
document.write("<br>");
}
</script>