到目前为止,我只能得到平均数字,但数量最多。
#! /bin/sh
# Get input numbers from user
echo Please enter three numbers
read a b c
# Calculate average of input numbers
avg=`expr \( $a + $b + $c \) / 3`
# Display the result
echo The average of the two input numbers is $avg
exit
答案 0 :(得分:0)
试试这个;
#! /bin/sh
# Get input numbers from user
echo Please enter three numbers
read a b c
# Calculate average of input numbers
avg=`expr \( $a + $b + $c \) / 3`
for i in $a $b $c ; do
((i > max)) && max=$i
done
echo The maximum number of the three input numbers is $max
# Display the result
echo The average of the three input numbers is $avg
exit