#!/bin/bash
#九九乘法表
i=1
while [ $i -le 9 ]
do
for (( j=1;j<=9;j++ ))
do
[ $j -le $i ]&& echo -n "$i$j=$((ij)) "
done
echo " "
let i++bash
doneide
1 1= 1
21=2 22=4
31=3 32=6 33=9
41=4 42=8 43=12 44=16
51=5 52=10 53=15 54=20 55=25
61=6 62=12 63=18 64=24 65=30 66=36
71=7 72=14 73=21 74=28 75=35 76=42 77=49
81=8 82=16 83=24 84=32 85=40 86=48 87=56 88=64
91=9 92=18 93=27 94=36 95=45 96=54 97=63 98=72 9*9=81 code
#!/bin/bash #直角三角形 i=1 while [ $i -lt 10 ] //變量i小於10 do j=1 while [ $j -le $i ] //變量j 小於等於變量i do echo -n x //輸出X j=$(($j+1)) done echo i=$(($i+1)) done exit 0 ~
x xx xxx xxxx xxxxx xxxxxx xxxxxxx xxxxxxxx xxxxxxxxx
#!/bin/bash #等腰三角形 i=1 while [ $i -le 10 ] ; do //變量i小於等於10 j=1 while [ $j -le $((10-$i)) ] ; do echo -n ' j=$(($j+1)) done j=1 while [ $j -le $((2*$i-1)) ] ; do echo -n x j=$(($j+1)) done echo i=$(($i+1)) done exit 0 ~
x xxx xxxxx xxxxxxx xxxxxxxxx xxxxxxxxxxx xxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx
#!/bin/bash read -p"請輸入菱形的長度: " fff for((i=1;i<=$fff;i++)) //控制行數 do for((j=$fff;j>i;j--)) //控制空格 do echo -n " " done let "g=2*i-1" for m in `seq 1 $g` //控制*數量,輸出2個 do echo -n "*" done echo "" done for((i=2;i<=$fff;i++)) do for ((j=1;j<i;j++)) do echo -n " " done let "k=2*(fff-i)+1"
#!/bin/bash read -p "請輸入正方形的長度: " ggg for ((i=1;$i<=$ggg;i++)) do for ((j=1;j<=$((2*$ggg));j++)) do echo -e "+\c" done echo done
[root@localhost ~]# ./ggg.sh 請輸入正方形的長度: 5 ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ [root@localhost ~]# ./ggg.sh 請輸入正方形的長度: 7 ++++++++++++++ ++++++++++++++ ++++++++++++++ ++++++++++++++ ++++++++++++++ ++++++++++++++ ++++++++++++++