【发布时间】:2013-12-04 21:57:05
【问题描述】:
我知道这是基本问题,但我无法在 unix 中编写简单的加法程序。我正在使用 cygwin 编写 shell 脚本 我的脚本是这样的
#!/bin/sh
echo "enter the first number"
read a
echo "enter the seconf number"
read b
echo [$a + $b]
【问题讨论】:
标签: unix
我知道这是基本问题,但我无法在 unix 中编写简单的加法程序。我正在使用 cygwin 编写 shell 脚本 我的脚本是这样的
#!/bin/sh
echo "enter the first number"
read a
echo "enter the seconf number"
read b
echo [$a + $b]
【问题讨论】:
标签: unix
#!/bin/sh
echo "enter the first number"
read a
echo "enter the seconf number"
read b
echo $(($a+$b))
【讨论】:
要添加两个数字,您可以这样做:
let c = $a + $b
echo $c
要阅读,你可以这样做:
read -p "Enter the first number" a
read -p "Enter the second number" b
【讨论】: