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
#!/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
相关文章推荐
- 查看: 35330 | 回复: 9 打印 上一主题 下一主题 [学习共享] 转:Shell 编程--本文结合大量实例阐述如何编写一个shell脚本
- shell 基本编程 打印菱形 三角形 乘法表
- shell脚本编程之终端打印
- shell脚本练习二(打印乘法表、等边三角形、菱形)
- shell 打印菱形 函数式编程
- shell 脚本编程要点
- 转:Shell 编程--本文结合大量实例阐述如何编写一个shell脚本。
- Shell脚本编程实战一:创建按天备份的脚本工具
- Shell 编程--本文结合大量实例阐述如何编写一个shell脚本
- centos shell脚本编程1 正则 shell脚本结构 read命令 date命令的用法 shell中的逻辑判断 if 判断文件、目录属性 shell数组简单用法 $( ) 和${ } 和$(( )) 与 sh -n sh -x sh -v 第三十五节课
- shell脚本:打印文本中字符数不大于6的单词
- 总结三种Shell脚本编程中避免SFTP输入密码的方法
- 关于shell脚本编程的10个最佳实践
- Shell脚本编程-流控制(一)
- Ubuntu下进行Shell脚本编程中[]的问题
- shell脚本编程之基础篇(二)
- 关于shell脚本编程的10个最佳实践
- 亿能测试大讲堂 - YY在线课程[ 测试人员需要掌握的Shell脚本编程 ]
- Linux下Shell脚本编程简介
- shell脚本编程之通配符