首页 > 系统服务 > 详细

shell脚本练习

时间:2019-09-07 23:54:21      阅读:154      评论:0      收藏:0      [点我收藏+]

三角形

#!/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 

 

shell脚本练习

原文:https://www.cnblogs.com/daisyyang/p/11483770.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!