当前位置:网站首页>使用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>
边栏推荐
- Tensorflow/Pytorch安装(Anaconda环境下,无版本冲突,亲测有效)
- C语言数组的深度分析
- target has libraries with conflicting names: libcrypto.a and libssl.a.
- LeetCode_22_Apr_4th_Week
- 文件编辑器
- 在AWS-EC2中安装Minikube集群
- 强化学习中,Q-Learning与Sarsa的差别有多大?
- 文件权限管理 ugo
- 【五一专属】阿里云ECS大测评#五一专属|向所有热爱分享的“技术劳动者”致敬#
- Tencent and NetEase have taken action one after another. What is the metaverse that is so popular that it is out of the circle?
猜你喜欢
第三章 标准单元库(上)
Shell脚本执行的三种方式
Detailed steps to install MySQL
Question 1000: Input two integers a and b, calculate the sum of a+b, this question is multiple sets of test data
Golang环境变量设置(二)--GOMODULE&GOPROXY
"A minute" Copy siege lion log 】 【 run MindSpore LeNet model
文件权限管理 ugo
Thunderbolt turns off automatic updates
迅雷关闭自动更新
Install Minikube Cluster in AWS-EC2
随机推荐
Amazon Cloud Technology Build On-Amazon Neptune's Knowledge Graph-Based Recommendation Model Building Experience
Postgresql snapshot
深度确定性策略梯度(DDPG)
深度学习,“粮草”先行--浅谈数据集获取之道
亚马逊云科技Build On-Amazon Neptune基于知识图谱的推荐模型构建心得
How to grow into a senior engineer?
[English learning][sentence] good sentence
ideal life
LeetCode_Nov_4th_Week
文件编辑器
第三章 标准单元库(下)
An abstract class, internal classes and interfaces
CSDN spree -- college round table spree
[开发杂项][VS Code]remote-ssd retry failed
集合--LinkedList
打金?工作室?账号被封?游戏灰黑产离我们有多近
Deep Learning Theory - Overfitting, Underfitting, Regularization, Optimizers
数据库的简述与常用操作指南
counting cycle
MNIST手写数字识别 —— Lenet-5首个商用级别卷积神经网络