如题所述
#!/bin/bash
#任意输入5个数,判断最大值,最小值,总和
s=0
read-p"pleaseinput:"num
s=$(($s+$num))
max=$num
min=$num
avg=$(($s/5))
foriin`seq4`
do
read-p"pleaseinput:"num
s=$(($s+$num))
if[$num-le$min];then
min=$num
fi
if[$num-ge$max];then
max=$num
fi
done
echomax:$maxmin:$minavg:$avg
扩展资料:
for循环:
一般格式为:
forvarinitem1item2...itemN
do
command1
command2
...
commandN
done
写成一行:
forvarinitem1item2...itemN;docommand1;command2?done;
温馨提示:答案为网友推荐,仅供参考