一实验要求
请用Shell编写程序输出菱形图形
二实验步骤
#!/bin/bash
for ((i=9; i>=1; i--))
do
for ((a=1; a<=$i; a++))
do
echo -n " "
done
for ((b=9; b>=$i; b--))
do
echo -n "*"
done
for ((c=8; c>=$i; c--))
do
echo -n "*"
done
echo ""
done
for ((i=2; i<=9; i++))
do
for ((a=1; a<=$i; a++))
do
echo -n " "
done
for ((b=9; b>=$i; b--))
do
echo -n "*"
done
for ((c=8; c>=$i; c--))
do
echo -n "*"
done
echo ""
done
输出结果如下: