A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

一.等腰三角形

<!DOCTYPE html>
<html lang="en">
<head>
        <meta charset="UTF-8">
        <title>Document</title>
</head>
<body>
        <script type="text/javascript">
                function show(row){
                        for (var i = 1; i < row; i++) {
                                for(var j=1;j<row-i;j++){
                                          document.write('&ensp;');
                                }
                                for(var k=1;k<=2*i-1;k++){
                                        document.write('*');
                                }document.write('<br>');
                        }
                }
                show(7);
        </script>
</body>
</html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
二.菱形

<!DOCTYPE html>
<html lang="en">
<head>
        <meta charset="UTF-8">
        <title>Document</title>
</head>
<body>
        <script type="text/javascript">
        function show(row){
                        for (var i = 1; i < row; i++) {
                                for(var j=1;j<row-i;j++){
                                          document.write('&ensp;');
                                }
                                for(var k=1;k<=2*i-1;k++){
                                        document.write('*');
                                }document.write('<br>');
                        }
                            for(var s=2;s<row;s++){
                                    for(var a=1;a<s;a++){
                                            document.write('&ensp;');
                                    }
                                    for(var b=1;b<=(row-a)*2-1;b++){
                                            document.write('*');
                                    }document.write('<br>');
                            }
                }
                show(7);
        </script>
</body>
</html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
三.九九乘法表

<!DOCTYPE html>
<html lang="en">
<head>
        <meta charset="UTF-8">
        <title>Document</title>
</head>
<body>
        <script type="text/javascript">
        function show(num){
             for(var i=1;i<num;i++){
              for(var a=1;a<=i;a++){
                 var b=a*i;
                 if (b<10) {
                    b='&ensp;'+b
                 }
                 document.write(a+'x'+i+'='+b+"&nbsp;&nbsp;&nbsp;")
              }document.write('<br>');
         }
        }show(10);
        </script>
</body>
</html>
---------------------
【转载,仅作分享,侵删】
作者:超哥要逆天
原文:https://blog.csdn.net/weixin_44382073/article/details/86222471


1 个回复

倒序浏览
奈斯
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马