for ((a=1;a<=9;a++))
do
for ((b=1;b<=a;b++))
do
c=$[a*b]
echo -n -e "$a*$b=$c\t"
done
echo " "
done
二.直线
#!/bin/bash
for ((i=1;i<=50;i++))
do
echo -n "*"
done
echo " "
三.矩形
#!/bin/bash
for ((i=1;i<=5;i++))
do
for ((a=1;a<=50;a++))
do
echo -n "*"
done
echo " "
done
四.直角三角形
1.正直角三角形
#!/bin/bash
for ((a=1;a<=15;a++))
do
for ((b=1;b<=a;b++))
do
echo -n "*"
done
echo ""
done
2.倒直角三角形
#!/bin/bash
for ((a=1;a<=15;a++))
do
for ((b=1;b<=a;b++))
do
echo -n " "
done
for ((c=15;c>=a;c--))
do
echo -n "*"
done
echo ""
done
五.等腰三角形
1.三角形拼接
#!/bin/bash
for ((a=1;a<=12;a++))
do
for ((b=12;b>=a;b--))
do
echo -n " "
done
for ((c=1;c<=a;c++))
do
echo -n "*"
done
for ((d=2;d<=a;d++))
do
echo -n "*"
done
echo ""
done
2.算法(2n-1)
#!/bin/bash
for ((a=1;a<=12;a++))
do
for ((b=12;b>=a;b--))
do
echo -n " "
done
for ((c=1;c<=a*2-1;c++))
do
echo -n "*"
done
echo ""
done
六.平行四边形
#!/bin/bash
for ((a=1;a<=12;a++))
do
for ((b=12;b>=a;b--))
do
echo -n " "
done
for ((c=1;c<=a;c++))
do
echo -n "*"
done
for ((d=11;d>=a;d--))
do
echo -n "*"
done
echo ""
done
七.直角梯形
1.左直角梯形
#!/bin/bash
for ((i=1;i<=10;i++))
do
for ((a=1;a<=8;a++))
do
echo -n "*"
done
for ((b=1;b<=i;b++))
do
echo -n "*"
done
echo " "
done
2.右直角梯形
#!/bin/bash
for ((i=1;i<=10;i++))
do
for ((a=10;a>=i;a--))
do
echo -n " "
done
for ((b=1;b<=i;b++))
do
echo -n "*"
done
for ((c=1;c<=11;c++))
do
echo -n "*"
done
echo " "
done
八.等腰梯形
#!/bin/bash
for ((i=1;i<=9;i++))
do
for ((a=9;a>=i;a--))
do
echo -n " "
done
for ((b=1;b<+9;b++))
do
echo -n "*"
done
for ((c=1;c<=$[i*2-1];c++))
do
echo -n "*"
done
echo " "
done
九.菱形(可调节大小)
#!/bin/bash
read -p "请输入大小:" s
for ((a=1;a<=s;a++))
do
for ((b=s;b>=a;b--))
do
echo -n " "
done
c=$[a*2-1]
for d in $(seq 1 $c)
do
echo -n "*"
done
echo ""
done
for ((e=s-1;e>=1;e--))
do
for ((f=s;f>=e;f--))
do
echo -n " "
done
for ((h=e;h>=1;h--))
do
echo -n "*"
done
for ((m=e-1;m>=1;m--))
do
echo -n "*"
done
echo ""
done