用shell寫的99乘法表

#!/bin/bash

for((i=1;i<=9;i++))
do
for((j=1;j<=${i};j++))
do
set x, y, temp,z
if [ ${#i} -eq 1 ]; then
x=0${i}
else
x=${i}
fi
if [ ${#j} -eq 1 ]; then
y=0${j}
else
y=${j}
fi
temp=$((ij))
if [ ${#temp} -eq 1 ]; then
z=0${temp}
else
z=${temp}
fi
if [ $j -eq $i ]; then
echo -e "\033[32m ${x}
${y}=${z}\033[0m"
else
echo -n -e "\033[32m ${x}*${y}=${z} \033[0m"
fi
done

done

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章