编写两个Shell程序kk及aa,在kk中输入两个数,调用aa计算计算这两个数之间奇数的和。

来源:互联网 发布:福州数据分析薪酬 编辑:程序博客网 时间:2024/05/20 19:48

kk:


#!/bin/shread -p "please input 2 integer:" a becho "a=$a,b=$b"./test9.sh $a $b

aa:


#!/bin/sha=$1b=$2sum=0temp=`expr $a % 2`if [ "$temp" -eq 1 ]then i=$awhile((i<=$b))do((sum+=i))((i+=2))doneecho "the result1 is $sum"elsei=$a+1while((i<=$b))do((sum+=i))((i+=2))doneecho "the result2 is $sum"fi


原创粉丝点击