javascript九九乘法表倒三角形输出
时间: 2023-05-19 09:06:27 浏览: 115
九九乘法表输出反三角
5星 · 资源好评率100%
以下是JavaScript实现九九乘法表倒三角形输出的代码:
```
for (var i = 9; i >= 1; i--) {
var row = '';
for (var j = 1; j <= i; j++) {
row += j + ' * ' + i + ' = ' + (i * j) + ' ';
}
console.log(row);
}
```
输出结果如下:
```
1 * 9 = 9
1 * 8 = 8 2 * 8 = 16
1 * 7 = 7 2 * 7 = 14 3 * 7 = 21
1 * 6 = 6 2 * 6 = 12 3 * 6 = 18 4 * 6 = 24
1 * 5 = 5 2 * 5 = 10 3 * 5 = 15 4 * 5 = 20 5 * 5 = 25
1 * 4 = 4 2 * 4 = 8 3 * 4 = 12 4 * 4 = 16 5 * 4 = 20 6 * 4 = 24
1 * 3 = 3 2 * 3 = 6 3 * 3 = 9 4 * 3 = 12 5 * 3 = 15 6 * 3 = 18 7 * 3 = 21
1 * 2 = 2 2 * 2 = 4 3 * 2 = 6 4 * 2 = 8 5 * 2 = 10 6 * 2 = 12 7 * 2 = 14 8 * 2 = 16
1 * 1 = 1 2 * 1 = 2 3 * 1 = 3 4 * 1 = 4 5 * 1 = 5 6 * 1 = 6 7 * 1 = 7 8 * 1 = 8 9 * 1 = 9
```
阅读全文