作者:手机用户2602920567 | 来源:互联网 | 2023-10-11 18:38
#!binbashread-p请输入第一个数:num1read-p请输入运算符:fuhaoread-p请输入第二个数num2if[$fuhao+]thenecho$num1+$nu
#!/bin/bash
read -p "请输入第一个数:" num1
read -p "请输入运算符:" fuhao
read -p "请输入第二个数" num2
if [ "$fuhao" == "+" ]
then
echo $num1+$num1=$(($num1 + $num2))
elif [ "$fuhao" == "-" ]
then
echo $num1-$num2=$(($num1 - $num2))
elif [ "$fuhao" == "*" ]
then
echo $num1*$num2=$(($num1 * $num2))
elif [ "$fuhao" == "/" ]
then
echo $num1/$num2=$(($num1 / $num2))
else
echo "错误"
fi