码迷,mamicode.com
首页 > 系统相关 > 详细

用shell写的99乘法表

时间:2018-05-25 10:58:03      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:Shell

#!/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

用shell写的99乘法表

标签:Shell

原文地址:http://blog.51cto.com/13765598/2120048

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!