javascript输出一个数字有序组成的三角形
1234567.....8...9..10.11.1213javascript编写的螺旋三角矩阵可复制使用的谢谢了...
1 2 3 4 5 6 7
. . . . . 8
. . . 9
. . 10
. 11
. 12
13
javascript
编写的螺旋三角矩阵
可复制使用的
谢谢了 展开
. . . . . 8
. . . 9
. . 10
. 11
. 12
13
javascript
编写的螺旋三角矩阵
可复制使用的
谢谢了 展开
2个回答
展开全部
<div id = "txt" />
<script type="text/javascript">
var div = document.getElementById("txt");
var txt = "";
var row = 7;
for(var i = 0 ;i < row ;){
txt += ++i + " ";
}
txt += "<br />"
for(var i =1 ;i < row ;i++){
for(var j = 0 ;j < row - i - 1 ;j++){
txt += " . ";
}
txt += (i + row) + "<br />"
}
div.innerHTML = txt;
</script>
更多追问追答
追问
哥我用的点是省略的意思 他都是用的数字是个螺旋的输出
给改改呗
追答
<div id = "txt" />
<script type="text/javascript">
var div = document.getElementById("txt");
var txt = "";
var row = 30;
for(var i =0 ;i < row ;i++){
for(var j = 0 ;j < row - i ;j++){
var num = (2*i+j+1);
if(num < 10)
num = num + " ";
num = num + " ";
txt += num;
}
txt += "<br />";
}
div.innerHTML = txt;
</script>
展开全部
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<script type="text/javascript">
for(var i = 1; i <= 13; i++){
var n = 13 - i;
if(n == 0){
n = '';
}else if(n == 1){
n = '.';
}else if(n == 2){
n = '..';
}else if(n == 3){
n = '...';
}else if(n == 4){
n = '....';
}else if(n == 5){
n = '.....';
}else if(n == 6){
n = '......';
}else{
n = '';
}
if(i == 7){
document.write(i + '<br />');
}else if(i > 7){
document.write(n + i + '<br />');
}else{
document.write(i);
}
}
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<script type="text/javascript">
for(var i = 1; i <= 13; i++){
var n = 13 - i;
if(n == 0){
n = '';
}else if(n == 1){
n = '.';
}else if(n == 2){
n = '..';
}else if(n == 3){
n = '...';
}else if(n == 4){
n = '....';
}else if(n == 5){
n = '.....';
}else if(n == 6){
n = '......';
}else{
n = '';
}
if(i == 7){
document.write(i + '<br />');
}else if(i > 7){
document.write(n + i + '<br />');
}else{
document.write(i);
}
}
</script>
</body>
</html>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询