东篱昏后

导航

 

三角形

#!/bin/bash
#等腰直角三角形
read -p "please input the length(等腰直角三角形): " n
for i in `seq 1 $n`
do 
    for ((j=$n;j>i;j--))
    do 
        echo -n " "
    done

    for m in `seq 1 $i`
    do 
        echo -n "* "
    done
    echo
done 

#倒直角三角形
read -p "please input the length(倒直角三角形): " len
for i in `seq 1 $len`
do 
    for j in `seq $i $len`
    do 
        echo -n "* "
    done
    echo 
done

#直角三角形
read -p "please input the length(直角三角形): " len
for i in `seq 1 $len`
do 
    for ((j=1;j<=$i;j++))
    do 
        echo -n "* "
    done
    echo
done

#菱形
read -p "please input the length(菱形): " n
for i in `seq 1 $n`
do 
    for ((j=$n;j>i;j--))
    do 
        echo -n " "
    done
    for m in `seq 1 $i` 
    do
        echo -n "* "
    done
    echo
done 

for i in `seq 1 $n`
do 
    for ((j=1;j<=$i;j++))
    do 
    echo -n " "
    done
    for ((k=$i;k<=$len-1;k++))
    do
        echo -n "* "
    done
    echo 
done 

 

posted on 2019-09-07 23:11  东篱昏后  阅读(196)  评论(0编辑  收藏  举报