function theOutputOne(n) {let star = '';for(let i = 0; i < n; i++) {star += '*' console.log(star)}
}
theOutputOne(11)
function theOutputTwo(n) {let star = '';for(let i = 0; i < n; i++) {let space = '';for(let j = 0; j < n - 1 - i; j++) {space += " ";}star += '*'console.log(space + star)}
}
theOutputTwo(11)
function theOutputThree(n) {for(let i = 0; i < n; i++){let star = "";for(let j = 0; j < 2 * i + 1; j++){star += "*";}let space= "";for(let j = 0; j < n - 1 - i; j++){space += " ";}console.log(space + star);}
}
function theOutputOneFour(n) {for(let i = 0; i < n; i++){let star = "";for(let j = 0; j < n - i; j++){star += "*";}console.log(star);}
}
theOutputOneFour(11)
function theOutputFive(n) {let star = "";for(let i = 0; i < n / 2; i++){star += "*";console.log(star);}for(let i = 0; i < parseInt(n / 2); i++){let star = "";for(let j = 0; j < parseInt(n / 2) - i; j++){star += "*";}console.log(star);}
}
theOutputFive(11)
就先写这几种吧,大家如果有需要其他类型的,可以评论区留言。或者大家有其他样式的写法也可以留言哦。
本文发布于:2024-02-02 19:13:57,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170687243445867.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |