javascript for循环问题。以下代码输入3会显示:112123.求高人修改后结果成:321211
<html><head><scriptlanguage="LiveScript">functionaaa(str){vara;a=str;vars="";for(vari...
<html>
<head>
<script language="LiveScript">
function aaa(str)
{
var a;
a = str;
var s = "";
for(var i = 1; i <= a; i++)
{
for(var j = 1; j <= i ;j++)
{
s = s + j + "";
}
}
document.write(s);
}
</script>
</head>
<body>
<form>
<input type="text" name="name" onclick="aaa(this.value)" value="">
</form>
</body>
</html> 展开
<head>
<script language="LiveScript">
function aaa(str)
{
var a;
a = str;
var s = "";
for(var i = 1; i <= a; i++)
{
for(var j = 1; j <= i ;j++)
{
s = s + j + "";
}
}
document.write(s);
}
</script>
</head>
<body>
<form>
<input type="text" name="name" onclick="aaa(this.value)" value="">
</form>
</body>
</html> 展开
2个回答
展开全部
<html>
<head>
<script language="LiveScript">
function aaa(str)
{
var a;
a = str;
var s = "";
for(var i = 1; i <= a; i++)
{
for(var j = a; j >= i ;j--) //倒过来不就可以了?
{
s = s + j + "";
}
}
document.write(s);
}
</script>
</head>
<body>
<form>
<input type="text" name="name" onclick="aaa(this.value)" value="">
</form>
</body>
</html>
<head>
<script language="LiveScript">
function aaa(str)
{
var a;
a = str;
var s = "";
for(var i = 1; i <= a; i++)
{
for(var j = a; j >= i ;j--) //倒过来不就可以了?
{
s = s + j + "";
}
}
document.write(s);
}
</script>
</head>
<body>
<form>
<input type="text" name="name" onclick="aaa(this.value)" value="">
</form>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<html>
<head>
<script language="LiveScript">
function aaa(str)
{
var a;
a = str;
var s = "";
for(var i = 0; i <= a; i++)
{
for(var j = a-i; j >=1 ;j--)//改动的地方
{
s = s + j + "";
}
}
document.write(s);
}
</script>
</head>
<body>
<form>
<input type="text" name="name" onclick="aaa(this.value)" value="3">
</form>
</body>
</html>
<head>
<script language="LiveScript">
function aaa(str)
{
var a;
a = str;
var s = "";
for(var i = 0; i <= a; i++)
{
for(var j = a-i; j >=1 ;j--)//改动的地方
{
s = s + j + "";
}
}
document.write(s);
}
</script>
</head>
<body>
<form>
<input type="text" name="name" onclick="aaa(this.value)" value="3">
</form>
</body>
</html>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询