JavaScript 九九乘法表

1.标准九九乘法表:
        document.write("");
        for (var i = 1; i <= 9; i++) {
            document.write("");
            for (var j = 1; j <= i; j++) {
                document.write("");
            }
            document.write("");
        }
        document.write("
" + j + "*" + i + "=" + i * j + "
");

打印结果如下:

2.九九乘法表(1)
        document.write("");
        for (var i = 1; i <= 9; i++) {
            document.write("");
            for (var n = i; n < 9; n++) {
                document.write("");
            }
            for (var j = i; j >= 1; j--) {
                document.write("");
            }
            document.write("");
        }
        document.write("
" + j + "*" + i + "=" + i * j + "
");

打印结果如下:

3.九九乘法表(2)
        document.write("");
        for (var i = 9; i >= 1; i--) {
            document.write("");
            for (var j = 1; j <= i; j++) {
                document.write("");
            }
            document.write("");
        }
        document.write("
" + j + "*" + i + "=" + i * j + "
");

打印结果如下:

4.九九乘法表(3)
        document.write("");
        for (var i = 9; i >= 1; i--) {
            document.write("");
            for (var j = 8; j >= i; j--) {
                document.write("");
            }
            for (var j = i; j >= 1; j--) {
                document.write("");
            }
            document.write("");
        }
        document.write("
" + j + "*" + i + "=" + i * j + "
");

打印结果如下:

可以参考我的博客地址:点击这里

你可能感兴趣的:(js,javascript)