标签:one done The bin 输入 -- nbsp 编写 方法
第一种方法
#!/bin/bash
read -p "请输入层数: " n
for (( i=1; i<=$n;i++ ))
do
for (( j=n; j>=i;j-- ))
do
echo -n " "
done
for (( j=1;j<=i;j++ ))
do
echo -n " *"
done
echo
done
另外一种方案:三角形简单
#!/bin/bash
for i in {1..9}
do
for a in {1..9}
do
if [ $a -ge $i ]
then
echo -n " "
fi
done
for b in {1..9}
do
if [ $b -le $i ]
then
echo -n "*"
fi
done
for h in {1..9}
do
if [ $h -lt $i ]
then
echo -n "*"
fi
done
echo
done
标签:one done The bin 输入 -- nbsp 编写 方法
原文地址:https://www.cnblogs.com/zc1741845455/p/10888797.html