题解 | #打印等腰三角形#
打印等腰三角形
https://www.nowcoder.com/practice/1c55ca2b73a34e80bafd5978810dd8ea
#!/bin/bash # 读取用户输入的正整数n read -p "" n # 循环打印等腰三角形 for ((i=1; i<=n; i++)); do # 打印前导空格 for ((j=n-i; j>0; j--)); do echo -n " " done # 打印星号和空格组合 for ((k=1; k<=i; k++)); do echo -n "* " done # 换行 echo done