- #!/bin/bash
- #for嵌套for循环
- #9*9乘法口诀
- echo "for的九九乘法表"
- for(( i=1 ;i<=9;i++ ))
- do
- for(( j=1;j<=9;j++ ))
- do
- #当$j小于等于$i,在屏幕上打印乘法表
- [ $j -le $i ] && echo -n "$i*$j=$[ $i * $j ] "
- done
- echo ‘‘
- done
- #9*9乘法口诀
- # echo "until的九九乘法表"
- # a=1
- # b=1
- # until [ $a -gt 9 ]
- # do
- # until [ $b -gt 9 ]
- # do
- # 当$j小于等于$i,在屏幕上打印乘法表
- # [ $b -le $a ] && echo -n "$a*$b=$[ $a * $b ] "
- # b=$[$b + 1]
- # done
- # echo ‘‘
- # a=$[$a + 1]
- # done
- #9*9乘法口诀
- # echo "while的九九乘法表"
- # i=1
- # j=1
- # while [ $i -lt 10 ]
- # do
- # while [ $j -lt 10 ]
- # do
- # 当$j小于等于$i,在屏幕上打印乘法表
- # [ $j -le $i ] && echo -n "$i*$j=$[ $i * $j ] "
- # j=$[ $j\+1 ]
- # done
- # echo ‘‘
- # i=$[ $i\+1 ]
- # done
- #9*9乘法口诀
- echo "while与for的九九乘法表"
- i=1
- while [ $i -lt 10 ]
- do
- for(( j=1;j<=9;j++ ))
- do
- #当$j小于等于$i,在屏幕上打印乘法表
- [ $j -le $i ] && echo -n "$i*$j=$[ $i * $j ] "
- done
- echo ‘‘
- i=$[ $i+1 ]
- done
- #9*9乘法口诀
- echo "until与for的九九乘法表"
- i=1
- until [ $i -gt 9 ]
- do
- for(( j=1;j<=9;j++ ))
- do
- #当$j小于等于$i,在屏幕上打印乘法表
- [ $j -le $i ] && echo -n "$i*$j=$[ $i * $j ] "
- done
- echo ‘‘
- i=$[ $i+1 ]
- done
- #9*9乘法口诀
- # echo "until与while的九九乘法表"
- # i=1
- # j=1
- # until [ $i -gt 9 ]
- # do
- # while [ $j -lt 10 ]
- # do
- # 当$j小于等于$i,在屏幕上打印乘法表
- # [ $j -le $i ] && echo -n "$i*$j=$[ $i * $j ] "
- # j=$[ $j+1 ]
- # done
- # echo ‘‘
- # i=$[ $i+1 ]
- # done
原文地址:https://www.cnblogs.com/hopelooking/p/9188920.html
时间: 2024-11-05 15:48:55