let readline = require("readline-sync");
console.log("请输入行数:");
let rows = ~~readline.question(‘‘)
let str = "";
let star = "";
for (let i = 1; i <= rows; i++) {
let str = "";
for (let k = 0; k < rows - i; k++) {
str += ` `;
}
for (let j = 1; j <= 2 * i - 1; j++) {
star += "*";
}
console.log(`${str}${star}`);
str = "";
star = "";
}
原文地址:https://www.cnblogs.com/huangshan-0809/p/9656803.html
时间: 2024-10-13 04:01:39