题解 | #求平均值#
求平均值
https://www.nowcoder.com/practice/c44b98aeaf9942d3a61548bff306a7de
#!/bin/bash read n sum=0 temp=0 for (( i=0;i<n;i++ )) do read temp sum=$(( sum+temp )); done #echo $sum echo $( echo "scale=3; $sum/$n" | bc )
求平均值
https://www.nowcoder.com/practice/c44b98aeaf9942d3a61548bff306a7de
#!/bin/bash read n sum=0 temp=0 for (( i=0;i<n;i++ )) do read temp sum=$(( sum+temp )); done #echo $sum echo $( echo "scale=3; $sum/$n" | bc )
相关推荐