今日任务
写一个函数,求数组中的和
#!/bin/bash
#写一个函数,求数组中元素的和
function sumfun(){
sum=0
for i in $*
do
((sum+=$i))
done
echo $sum
}
arr=(1 2 3 4 5 6)
sumfun ${arr[*]}
运行结果:
通过break实现打印九九乘法表
#!/bin/bash
#break 打印九九乘法表
for i in `seq 1 9`
do
for j in `seq 1 9`
do
if [ $j -gt $i ]
then
break
fi
echo -n "${i}x${j}=$((i*j)) "
done
echo
done
运行结果
今日思维导图
c高级就此结束,it seems like a little,but still has lots of order to remmer.
there is a old saying, load hard and long