您的位置:首页 > 运维架构 > Shell

shell下打印菱形(一起熟悉shell脚本编程)

2010-04-06 09:17 731 查看
用vi创建以文档名为:test.sh
#!/bin/bash
a() {
k=1
while [$k -le $B ]; do
let k++
echo -n " "
}
b() {
j=1
while [ $j -le $C ]; do
let j++
echo -n "*"
done
}
c() {
s=1
while [ $s -le $h ]; do
let s++
echo -n " "
done
}
d() {
m=1
while [ $m -le $D ]; do
let m++
echo -n "*"
done
}
read -p "Please input the number(1-10):" nu
i=0
while [ $i -lt $nu ]; do
let i++
B=`expr $nu -$i`
C=`expr 2 \* $i - 1`
a
b
echo ""
done
nua=`expr $nu - 1`
h=0
while [ $h -lt $nua ]; do
let h++
E=`expr 2 \* $h - 1`
D=`expr 2 \* $nua -$E`
c
d
echo ""
done

执行结果
#sh test.sh


'700')this.width='700';if(this.height>'700')this.height='700';" border=0> 本文出自 “纵成水势,点滴皆泽。” 博客,请务必保留此出处http://jiaze.blog.51cto.com/340608/291488
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: