本文介绍了如何打印:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何打印:
***
**
*
我尝试过:
how to print this:
***
**
*
What I have tried:
<!DOCTYPE html>
<html>
<head>
<title>reverse</title>
</head>
<body>
<script>
var n=prompt("enter your limit");
for(i=1;i<=n;i++)
{
document.write("<br>");
for(j=1;j>=i;j++)
{
document.write("*");
}
}
</script>
</body>
</html>
推荐答案
// Outer Loop, which does control the column length
for (noOfColumns= limit; noOfColumns >=1; noOfColumns--)
{
// here we have noOfColumns which means how many "*" we Need to print.
// So lets print from 1 to columns
for (j= 1; j <= noOfcolumns; j++)
{
document.write("*");
}
// Current line is finished
document.write("<br>");
}
我希望它有所帮助。请不要简单地复制和粘贴。试着理解它;)
I hope it helps. Please do not simply copy&paste. Try to understand it ;)
引用:
如何打印这个:
旅行代码给予
*
**
***
*** *
*****
你想要
*****
****
***
**
*
说不然,你有:
f(1)= 1,f(2)= 2,f(3)= 3,f(4)= 4,f(5)= 5
你想要
f(1)= 5,f(2)= 4,f(3)= 3,f(4)= 2,f(5)= 1
你不能设备公式pf f()?
这真的不复杂。
Tour code gives
*
**
***
****
*****
and you want
*****
****
***
**
*
Said otherwise, you have:
f(1)= 1, f(2)= 2, f(3)=3, f(4)= 4, f(5)= 5
and you want
f(1)= 5, f(2)= 4, f(3)=3, f(4)= 2, f(5)= 1
Can't you device the formula pf f() ?
It is really not complicated.
这篇关于如何打印:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!