<!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> </head> <body> </body> </html> <script> // 打印一个空心菱形图案 for(var i = 1; i <=6 ; i++){ for(var k = 1 ; k<=6-i; k++){ document.write("-"); } for(var j = 1 ; j<=i*2-1; j++){ if(i == 1){ document.write("*"); }else if(j == 1 || j == i*2-1){ document.write("*"); }else{ document.write("-"); } } document.write("<br>"); } for(var i = 5; i >=1 ; i--){ for(var k = 1 ; k<=6-i; k++){ document.write("-"); } for(var j = 1 ; j<=i*2-1; j++){ if(i == 1){ document.write("*"); }else if(j == 1 || j == i*2-1){ document.write("*"); }else{ document.write("-"); } } document.write("<br>"); } </script>
原文地址:https://www.cnblogs.com/lsqbk/p/10258957.html
时间: 2024-09-27 16:22:43