Shell-求平均
Compute the Average Given integers,compute their average correct to three decimal places. Input Format lines follow,each containing a single integer. Output Format integers,rounded off to three decimal places. Input Constraints ( refers to elements of the list of integers for which the average is to be computed) Sample Input 4 Sample Output 5.000 Explanation read n arr=($(cat)) arr=${arr[*]} printf "%.3f" $(echo $((${arr// /+}))/$n | bc -l) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |