3个shell的小脚本的练习
1;打印9*9乘法表
2;输出国际象棋的棋盘
3;猴子;摘了n个香蕉
每天,吃一半,+1
第九天剩一个
求摘了几个香蕉
1;打印99乘法表
一:
for i in {1..9}
do
for j in seq $i
do
echo -n “$i$j=$(i*j) ”
done
echo
done
方法二:
#!/bin/bash
for i in {1..9}
do
for j in {1..9}
do
[ $j -gt $i ] && break
echo -n "$i$j=$[ij] "
done
echo
Done
2;输出国际象棋的棋盘
#!/bin/bash
for i in {1..4}
do
for j in {1..4}
do
echo -ne "\033[40m==\033[0m"
echo -ne "\033[49m||\033[0m"
done
echo
for a in {1..4}
do
echo -ne "\033[49m||\033[0m"
echo -ne "\033[40m==\033[0m"
done
echo
done
echo
3;猴子;摘了n个香蕉
每天,吃一半,+1
第九天剩一个
求摘了几个香蕉
#!/bin/bash
a=1
for i in {1..8}
do
let a=(a+1)*2
done
echo $a
相关文章