shell指令碼寫乙個99乘法表

2021-10-01 17:41:51 字數 398 閱讀 6690

#! /bin/bash

for i in `seq 1 9` #外層迴圈負責列印行…注意 `seq 1 9` 使用反引號括起來的(不是單引號),表示命令替換

do for j in `seq 1 $i` #內層迴圈負責列印列…在shell指令碼中,使用變數時 需要在變數名之前加上$號

do #迴圈體的邊界,使用do和done進行描述

echo -ne "$j*$i=$[$j*$i]\t" #$連著,表示算術運算…因為\t是轉義字元 所以需要-e,-n表示取消換行(需要「連打」)

done

echo #這個echo的作用:每次內層迴圈結束之後,進行換行(echo預設換行)

done

shell指令碼程式設計實現9 9乘法表

指令碼內容 複製 如下 ndkwxfbh bin bash for i in 1 2 3 4 5 6 7 8 9 do for j in 1 2 3 4 5 6 7 8 9 do nbwww.cppcns.comsp if lt then k i j echo n t fi if eq then k...

shell程式設計9 9乘法表

指令碼內容 bin bash for i in 1 2 3 4 5 6 7 8 9 do for j in 1 2 3 4 5 6 7 8 9 doif lt then k i j echo n t fiif eq then k i j echo fidone done輸出結果 iufo iufo ...

99乘法表指令碼 shell and python

以下例項演示了如何實現九九乘法表 shell方式 usr bin env bash for a 1 a 9 a do for b 1 b 9 b doif a ge b then echo n b a a b fidone echo doneshell設計思路 設定兩個個變數a和b,a和b的起始值都...