当前位置:网站首页>使用JS在浏览器中打印菱形
使用JS在浏览器中打印菱形
2022-08-04 05:31:00 【look up at the stars】
打印菱形:(当页面加载完毕时根据弹出的提示信息输入想要打印的菱形的行数。注释:输入的数字为菱形的行数一半+1)
例如下图即输入6以后打印的图形。
示例代码:
<script type="text/javascript">
var num=prompt("请输入打印的行数:","");
for (var i=1;i<=num;i++){
document.write(" ");
for (var k=num;k>=i;k--){
document.writeln(" ");
}
for (var j=1;j<=2*i-1;j++){
if(j%2==0){
document.writeln(" ");
}else{
document.writeln("*");
}
}
document.write("<br/>");
}
for (var i=num-1;i>=1;i--){
document.write(" ");
for (var k=num;k>=i;k--){
document.writeln(" ");
}
for (var j=1;j<=2*i-1;j++){
if(j%2==0){
document.writeln(" ");
}else{
document.writeln("*");
}
}
document.write("<br/>");
}
</script>
边栏推荐
- The second official example analysis of the MOOSE platform - about creating a Kernel and solving the convection-diffusion equation
- Completely remove MySQL tutorial
- FAREWARE ADDRESS
- IDEA创建Servlet步骤
- 线性表之动态数组(ArrayList)的自实现
- 结构体传参-C语言
- 集合--LinkedList
- Pytest常用插件
- An abstract class, internal classes and interfaces
- target has libraries with conflicting names: libcrypto.a and libssl.a.
猜你喜欢

Detailed steps to install MySQL

Deep learning, "grain and grass" first--On the way to obtain data sets

C语言数组的深度分析
![[Deep Learning Diary] Day 1: Hello world, Hello CNN MNIST](/img/06/6f49260732e5832edae2ec80aafc99.png)
[Deep Learning Diary] Day 1: Hello world, Hello CNN MNIST

LeetCode_Dec_1st_Week

Copy Siege Lions "sticky" to AI couplets

tmux概念和使用

MOOSE平台使用入门攻略——如何运行官方教程的例子

【Copy攻城狮日志】飞浆学院强化学习7日打卡营-学习笔记

Copy Siege Lion 5-minute online experience MindIR format model generation
随机推荐
线性表之动态数组(ArrayList)的自实现
MNIST Handwritten Digit Recognition - From Perceptrons to Convolutional Neural Networks
C语言结构体(必须掌握版)
(Navigation page) OpenStack-M version - manual construction of two nodes - with video from station B
MNIST Handwritten Digit Recognition - Image Analysis Method for Binary Classification
卷积神经网络入门详解
多线程顺序输出
IEEE802.X协议族
"A minute" Copy siege lion log 】 【 run MindSpore LeNet model
AWS uses EC2 to reduce the training cost of DeepRacer: DeepRacer-for-cloud practical operation
LeetCode_Dec_2nd_Week
【Copy攻城狮日志】“一分钟”跑通MindSpore的LeNet模型
LeetCode_Nov_4th_Week
The usefulness of bind() system call
Object.requireNonNull 方法说明
【深度学习日记】第一天:Hello world,Hello CNN MNIST
文件权限管理 ugo
Deep learning, "grain and grass" first--On the way to obtain data sets
[开发杂项][VS Code]remote-ssd retry failed
C语言静态变量static的分析