标签:16px += space star read lin 根据 i++ line
正星星
let readline=require("readline-sync");
console.log("请输入行数");
let line=readline.question("");
let strspace="";
let strstar="";
let str="";
//该层for循环控制星星的行数
for(let i=1;i<=line;i++){
//该层for循环控制空格数
for(let j=1;j<=line-i;j++){
strspace=strspace+" ";
}
for(let k=1;k<=2*i-1;k++){
strstar=strstar+"*";
}
str=strspace+strstar;
console.log(str);
str="";
strspace="";
strstar="";
}
let readline=require("readline-sync");
console.log("请输入行数");
let line=readline.question("");
let strspace="";
let strstar="";
let str="";
for(let i=1;i<=line;i++){
for(let j=1;j<=i;j++){
strspace +=" ";
}
for(let k=1;k<=2*(line-i)+1;k++){
strstar+="*";
}
str=strspace+strstar;
console.log(str);
str="";
strspace="";
strstar="";
}
标签:16px += space star read lin 根据 i++ line
原文地址:https://www.cnblogs.com/youwei716/p/11146120.html