Multiplication statement // for (i1; I & lt; 9; I ++) {// control row // for (j1; j & lt; I; j ++) {// control // document. write (I + & quot; * & quot; + j + & quot; + (I * j) + & quot; & amp; nbsp & quot ;); ///} // document. write (& quot; & lt
Multiplication
// For (I = 1; I <= 9; I ++) {// control row
// For (j = 1; j <= I; j ++) {// Control
// Document. write (I + "*" + j + "=" + (I * j) + "");
//}
// Document. write ("
");
//}
/*
*
***
*****
*/
// For (I = 1; I <= 5; I ++) {// control row
// For (j = 1; j <= 2 * I-1; j ++) {// Control
// Document. write ("*");
//}
// Document. write ("
");
//}
/*
*
***
*****
*******
*********
***********
*************
***************
*****************
*******************
*/
// For (I = 1; I <= 10; I ++ ){
//// Print space
// For (t = 1; t <= 10-I; t ++ ){
// Document. write ("");
//}
// For (j = 1; j <= 2 * I-1; j ++ ){
// Document. write ("*");
//}
// Document. write ("
");
//}
// Print the diamond Graph
// For (I = 1; I <= 5; I ++ ){
//// Print space
// For (t = 1; t <= 5-i; t ++ ){
// Document. write ("");
//}
// For (j = 1; j <= 2 * I-1; j ++ ){
// Document. write ("*");
//}
// Document. write ("
");
//}
/*
Number of rows, number of stars, number of spaces
*/
For (I = 4; I> = 1; I --){
// For (t = 4; t> = I; t --)
For (t = 5-i; t> = 1; t --)
{
Document. write ("");
}
For (j = 1; j <= 2 * I-1; j ++ ){
Document. write ("*");
}
Document. write ("
");
}
You can use the for loop to implement some related images.
For example, print the diamond:
*
***
*****
*******
*********
*******
*****
***
*
// Print the diamond Graph
For (I = 1; I <= 5; I ++ ){
// Print space
For (t = 1; t <= 5-i; t ++ ){
Document. write ("");
}
For (j = 1; j <= 2 * I-1; j ++ ){
Document. write ("*");
}
Document. write ("
");
}
/*
Number of rows, number of stars, number of spaces
*/
For (I = 4; I> = 1; I --){
// For (t = 4; t> = I; t --)
For (t = 5-i; t> = 1; t --)
{
Document. write ("");
}
For (j = 1; j <= 2 * I-1; j ++ ){
Document. write ("*");
}
Document. write ("
");
}
/*
*
**
**
**
*****
*/
For (I = 1; I <= 5; I ++)
{
// Print space
For (t = 1; t <= 5-i; t ++)
{
Document. write ("");
}
For (j = 1; j <= 2 * I-1; j ++)
{
// Print other rows except the last row, with spaces in the first and last columns.
If (I <5)
{
If (j = 1 | j = 2 * i-1)
Document. write ("*");
Else
Document. write ("");
}
Else // last line, odd *, even space
{
If (j % 2! = 0)
Document. write ("*");
Else
Document. write ("");
}
}
Document. write ("
");
}
Print triangle
Var k = prompt ("Enter the number of printed rows :","");
For (var I = 1; I <= k; I ++)
{
For (varj = 0; j
{
Document. write ("*");
}
Document. write ("
");
}
Script
From Aweijun360