Shell-求平均
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-求平均的更多相关文章
- 实验12:Problem F: 求平均年龄
Home Web Board ProblemSet Standing Status Statistics Problem F: 求平均年龄 Problem F: 求平均年龄 Time Limit: ...
- OpenJudge计算概论-求平均年龄
/*============================================== 求平均年龄 总时间限制: 1000ms 内存限制: 65536kB 描述 班上有学生若干名,给出每名学 ...
- HDOJ2023求平均成绩
求平均成绩 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- hdoj 2023 求平均成绩
求平均成绩 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- order by跟group by 跟having----------------sum() 求和 avg()求平均 count() 求个数--------------like
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoEAAACdCAIAAABEujUmAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWX ...
- 杭电ACM求平均成绩
求平均成绩 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Subm ...
- Numpy 学习 array np.where lexsort 切片 按行按列求平均mean
array 的创建可以通过list给 array print出来像一个表格,可以按行按列来观察. 原来是一个list相当于一行 np.where用于寻找一个condition下的坐标,返回的是一个2个 ...
- 计算概论(A)/基础编程练习2(8题)/1:求平均年龄
#include<stdio.h> int main() { // 声明与初始化 , s=, age=; // 输入学生人数 scanf("%d", &n); ...
- HDU2023求平均成绩 - biaobiao88
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2023 求平均成绩 Problem Description 假设一个班有n(n<=50)个学生,每 ...
- awk统计命令(求和、求平均、求最大值、求最小值)
本节内容:awk统计命令 1.求和 cat data|awk '{sum+=$1} END {print "Sum = ", sum}' 2.求平均 cat data|awk '{ ...
随机推荐
- bzoj2333 离线 + 线段树
https://www.lydsy.com/JudgeOnline/problem.php?id=2333 有N个节点,标号从1到N,这N个节点一开始相互不连通.第i个节点的初始权值为a[i],接下来 ...
- Event Recommendation Engine Challenge分步解析第四步
一.请知晓 本文是基于: Event Recommendation Engine Challenge分步解析第一步 Event Recommendation Engine Challenge分步解析第 ...
- Django基于正则表达式匹配URL
在Django1.X中,是这样匹配的. 在Django2.X中,是这样匹配的. Django2.X中开始需要用re_path模块进行正则表达式匹配了,太JB坑了,卡了好久这个问题,最后还是问群里面的高 ...
- python模块之collections random
collections 在内置数据类型(list, dict, tuple, set)的基础上,collections提供了几个额外的数据类型: Counter, deque, Orderdict, ...
- Java入门系列 泛型
前言 <Java编程思想>第四版足足用了75页来讲泛型——厚厚的一沓内容,很容易让人头大——但其实根本不用这么多,只需要一句话:我是一个泛型队列,狗可以站进来,猫也可以站进来,但最好不要既 ...
- 保存页面数据的场所----Hidden、ViewState、ControlState
1.使用隐藏域Session.Application和Cache都是保存在服务器内存中的.一般来说我们是无权访问客户端的机器,把数据直接保存在客户端的(Cookie是一个例外,不过Cookie只能保存 ...
- storm+Calcite
敬请期待... http://blog.csdn.net/yu616568/article/details/49915577 https://github.com/terry-chelsea/bigd ...
- Session 起航 登录会话和注销请求 重定向和转发
[LoginServlet] @WebServlet(name="loginServlet",urlPatterns = "/login") public cl ...
- MySQL api
今天看去年年中写的代码,留意到一个关键时刻能提高效率的api:on duplicate key update: 语法: INSERT INTO INSERT INTO g_iot_user_build ...
- Docker 容器暂停服务 - 七
docker pause :暂停容器中所有的进程docker unpause :恢复容器中所有的进程 docker pause [OPTIONS] CONTAINER [CONTAINER...] d ...