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 '{ ...
随机推荐
- CodeForces1065F 树形dp
http://codeforces.com/problemset/problem/1065/F 你有一棵带有n个结点的树,根是结点1.有一个标记,最初在根结点处.你可以将标记移动到其他结点处.假设标记 ...
- InnoDB和MyISAM的区别
一.索引的实现 我们都知道InnoDB和MyISAM都是B+数的结构,但是它们的实现有点不一样,直接上图: 因此,MyISAM的查询性能会比InnoDB强 如果用InnoDB是必须有主键的,主键建议用 ...
- python脚本难点
本文主要记录在录制过程中,遇到一些需要特殊处理的脚本.如果有总结不好的地方,希望多多指点. 一.输入框listview选择: 如图: 类似这种情况,选择其中一项的脚本如下: m = driver. ...
- 用itext合并多个pdf文件【转】【补】
java代码 package c; import java.io.FileOutputStream; import java.io.IOException; import java.util.Arra ...
- Springboot中Feign的使用总结
Feign是Webservice服务的客户端,创建接口+注解就可完成,实现简单 客户端通过@EnableFeignClients开启Feign的支持功能 @SpringBootApplication ...
- impala系列: 同步Hive元数据和收集统计信息
---====================-- Impala 获取hive 的 metadata ---====================Impala 通常和Hive共用同一个metadat ...
- 什么是CMD
cmd是command的缩写.命令提示符是在操作系统中,提示进行命令输入的一种工作提示符.在不同的操作系统环境下,命令提示符各不相同. 在windows环境下,命令行程序为cmd.exe,是一个32位 ...
- MVC 自定义路由
RouteConfig.cs 代码如下: public class RouteConfig { public static void RegisterRoutes(RouteCollection ro ...
- Redis Fun使用
using Newtonsoft.Json; using StackExchange.Redis; using System; using System.Configuration; using Sy ...
- luogu P4931 情侣?给我烧了!
双倍经验 传送门 首先坐在一起的cp和不坐在一起的cp是相对独立的,可以分开考虑,然后方案数相乘 坐在一起的cp,方案为\(\binom{n}{k}*\binom{n}{k}*k!*2^k\).首先选 ...