标签:number read ber 不能 cti 计算器 shel 输入 ase
1、计算器
#!/bin/bash
#test
#by authors hdc 2018
function add(){
c=$[ $a + $b ]
echo $c
}
function sub(){
c=$[$a - $b]
echo $c
}
function mul(){
c=$[ $a * $b ]
echo $c
}
function devide(){
if [ $b -eq 0 ];then
echo "分母不能为0"
read -p "请重新输入第二个操作数:" b
fi
c=$[ $a / $b ]
echo $c
}
i="ddf"
while [[ -n "Si" ]]
do
read -p "请输入要执行打操作:" i
if [[ -z "$i" ]];then
echo "结束运行"
exit
fi
read -p "Please input the number1:" a
read -p "Please input the number2:" b
case $i in
add )
add
;;
sub )
sub
;;
mul )
mul
;;
devide )
devide
;;
* )
echo "输入错误,请重新输入!"
;;
esac
done
标签:number read ber 不能 cti 计算器 shel 输入 ase
原文地址:https://www.cnblogs.com/hdc520/p/10209656.html