Compute the Average

Given

integers, compute their average correct to three decimal places.

Input Format

The first line contains an integer,

.

lines follow, each containing a single integer.

Output Format

Display the average of the

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

1

2

9

8

Sample Output

5.000

Explanation

The '4' in the first line indicates that there are four integers whose average is to be computed. The average = (1 + 2 + 9 + 8)/4 = 20/4 = 5.000 (correct to three decimal places) Please include the zeroes even if they are redundant (e.g. 0.000 instead of 0).


read n
arr=($(cat))
arr=${arr[*]}
printf "%.3f" $(echo $((${arr// /+}))/$n | bc -l)

Shell-求平均的更多相关文章

  1. 实验12:Problem F: 求平均年龄

    Home Web Board ProblemSet Standing Status Statistics   Problem F: 求平均年龄 Problem F: 求平均年龄 Time Limit: ...

  2. OpenJudge计算概论-求平均年龄

    /*============================================== 求平均年龄 总时间限制: 1000ms 内存限制: 65536kB 描述 班上有学生若干名,给出每名学 ...

  3. HDOJ2023求平均成绩

    求平均成绩 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  4. hdoj 2023 求平均成绩

    求平均成绩 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  5. order by跟group by 跟having----------------sum() 求和   avg()求平均   count() 求个数--------------like

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoEAAACdCAIAAABEujUmAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWX ...

  6. 杭电ACM求平均成绩

    求平均成绩 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Subm ...

  7. Numpy 学习 array np.where lexsort 切片 按行按列求平均mean

    array 的创建可以通过list给 array print出来像一个表格,可以按行按列来观察. 原来是一个list相当于一行 np.where用于寻找一个condition下的坐标,返回的是一个2个 ...

  8. 计算概论(A)/基础编程练习2(8题)/1:求平均年龄

    #include<stdio.h> int main() { // 声明与初始化 , s=, age=; // 输入学生人数 scanf("%d", &n); ...

  9. HDU2023求平均成绩 - biaobiao88

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2023 求平均成绩 Problem Description 假设一个班有n(n<=50)个学生,每 ...

  10. awk统计命令(求和、求平均、求最大值、求最小值)

    本节内容:awk统计命令 1.求和 cat data|awk '{sum+=$1} END {print "Sum = ", sum}' 2.求平均 cat data|awk '{ ...

随机推荐

  1. Vue computed属性

    computed vs methods 我们可以使用Vue中的method计算出学科的总分,最终得到的总数结果是相同的. 在上例的基础上,我们把computed区块中的totalMarks函数整体移到 ...

  2. JavaSE_坚持读源码_Object对象_Java1.7

    /** * Returns a hash code value for the object. This method is * supported for the benefit of hash t ...

  3. Ubuntu修改Apache默认Web端口

    改成你要的端口,默认为80,这里我改成了8080,https改成了444,保存之后寻找000/default.conf并修改成和ports.conf文件一样的http端口,然后重启Apache服务器即 ...

  4. Linux 内核里的数据结构:红黑树(rb-tree)

    转自:https://www.cnblogs.com/slgkaifa/p/6780299.html 作为一种数据结构.红黑树可谓不算朴素.由于各种宣传让它过于神奇,网上搜罗了一大堆的关于红黑树的文章 ...

  5. JSON.parse JSON.stringify

    JSON.stringify() undefined 值.函数或者XML值会被忽略 数组当中含有 undefined值,函数或XML值,该数组中的这些值将会被当成 null 正则对象会被转成空对象 J ...

  6. TPS和QPS的区别和理解【转】

    QPS:Queries Per Second意思是“每秒查询率”,是一台服务器每秒能够相应的查询次数,是对一个特定的查询服务器在规定时间内所处理流量多少的衡量标准. TPS:是Transactions ...

  7. tedu训练营day01

    1.三大操作系统 1.Unix :MacOS 2.Linux :Ubuntu18.04 .CentOS.RedHat 3.Windows :Win7.Win8.Win102.VMware Workst ...

  8. Silverlight 样式的灵活使用

    众所周知,Silverlight将界面设计与代码实现分开.即便如此,如果不能灵活地运用样式Style,开发的效率依然会比较低.比如,针对类似的TextBlock,你可能需要反复地在设计器xaml中复制 ...

  9. json日期字符串格式化时间

    var str = '/Date(1333245600000+0800)/';   function data_string(str) {     var d = eval('new ' + str. ...

  10. jsp 起航 和Servlet通过attribute通信

    @WebServlet(name = "ticketServlet",urlPatterns = {"/tickets"},loadOnStartup = 1) ...