手动输入菱形的行数 ,打印出菱形
echo "Please input data"
read k //读入手动输出的行数
i=1
while [ $i -le $k ]
do
let ban=k/2+1 //菱形的上半部
if [ $i -le $ban ]
then
j=1
while [ $j -le `expr $ban - $i` ]
do
printf " "
let j++
done
n=1;
let xing=i*2-1
while [ $n -le $xing ]
do
printf "*"
let n++
done
printf "\n"
else //菱形的下半部分
j=1
while [ $j -le `expr $i - $ban` ]
do
printf " "
let j++
done
n=1
let xing1=k-i*2+ban*2
while [ $n -le $xing1 ]
do
printf "*"
let n++
done
printf "\n"
fi
let i++
done