Linux用shell脚本执行乘法口诀表的两种方式

复制代码
#!/bin/bash
# *********************************************************#
#                                                          #
# * Author        : 藻头男                                  #
# * QQ邮箱        : 2322944912@qq.com                      #
# * Create time   : 2024-01-02-21-00-00                    #
# * Filename      : cheng.sh                               #
# * Description   : This is Shell scripts                  #
#                                                          #
#                                                          #
# ********************************************************#
 clear    #清屏执行 
#第一种方法for循环
 for i in {1..9}
 do
 for o in `seq $i`
 do
     echo -n -e "$o x $i = $[$i*$o]\t"
 done
    echo
 done 

echo "" 

#第二种方法while循环
 a=0
 while [ $a -lt 9 ]
 do
    let a++
 b=0
        while [ $b -lt $a ]
        do
             let b++
             echo -ne "$b x $a = $[$b*$a]\t"     
        done    
             echo
 done

感谢观看!希望能够帮助到大家!

相关推荐
半仙白桑21 分钟前
内核篇第十五讲:system-V共享内存
linux·共享内存·shmget·shmat·shmdt·shmctl
知行产研33 分钟前
易控智驾:毛利率跃升17.2个百分点,矿山无人驾驶从“规模换增长“迈入“盈利拐点“
数据库·mysql
一条破秋裤38 分钟前
Linux 线程创建:pthread_create 与基本回收
java·linux·运维
可涵不会debug1 小时前
第一次学 LangGraph:用一个快递案例搞懂 State、Node、Edge 和 compile
服务器·数据库·mysql
s6516654962 小时前
IDT和GDT是什么
linux
用户250458106092 小时前
数据库索引为什么会失效?从执行计划理解 SQL 性能优化
sql·mysql
Android系统攻城狮2 小时前
Linux Gstreamer深度解析之gst_audio_decoder_set_estimate_rate调用流程与实战(四十五)
linux·gstreamer音视频·音视频进阶
Web极客码2 小时前
抹平首包开销:我用 Claude 调优 Nginx 的 Brotli 与 Gzip 动态压缩,平衡 CPU 与网络吞吐
服务器·agent 工作流·agent 图
FED_AF3 小时前
Linux运维“邪修”功法之通配符
linux·运维
箓维3 小时前
线程的概念和理解
linux