linux 版菱形

 

#!/bin/sh
read -p "Input line number: " line
for((i=0;i<$line;i++))
do
for((k=i+1;k<$line;k++))
do
echo -n " "
done
for((j=0;j<$((2*$i+1));j++))
do
echo -n "*"
done
echo
done

 

 

for ((i=1; i<$line; i++))
do
for ((k=$i; k>0; k--))
do
echo -n " "
done
for ((h=$((2*($line-$i)-1)); h>0; h--))
do
echo -n "*"
done
echo
done

posted @ 2018-01-20 22:52  zhgs_cq  阅读(200)  评论(0编辑  收藏  举报