代码:

#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std; double a[100000]; int main()
{
int n;
double s;
while(scanf("%d",&n)==1)
{
s=0;
for(int i=0; i<n; i++)
{
scanf("%lf",&a[i]);
s+=a[i];
}
s/=(n*1.0);
double ans=0;
for(int i=0; i<n; i++)
{
ans+=((a[i]-s)*(a[i]-s));
}
ans/=(n*1.0);
ans=sqrt(ans);
printf("%.5lf\n",ans);
}
return 0;
}

pat 2-05. 求集合数据的均方差(水题)的更多相关文章

  1. PAT 2-05. 求集合数据的均方差(15)

    题目意思:求N个给定整数的均方差. 求平均值需要先转化为double类型,如果没转化会损失精度,造成错误. 代码如下: #include<iostream> #include<cma ...

  2. [PAT]求集合数据的均方差(15)

    #include "stdio.h" #include "malloc.h" #include "math.h" int *getinput ...

  3. 2-05. 求集合数据的均方差(15) (数学啊 ZJU_PAT)

    题目链接:http://pat.zju.edu.cn/contests/ds/2-05 设计函数求N个给定整数的均方差.若将N个数A[]的平均值记为Avg,则均方差计算公式为: 输入格式说明: 第1行 ...

  4. NBUT 1186 Get the Width(DFS求树的宽度,水题)

    [1186] Get the Width 时间限制: 1000 ms 内存限制: 65535 K 问题描述 It's an easy problem. I will give you a binary ...

  5. hdu 2005 求第几天(水题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2005 转载于:https://blog.csdn.net/tigerisland45/article/ ...

  6. 洛谷P1466 集合 Subset Sums_01背包水题

    不多解释,适当刷刷水… Code: #include<cstdio> #include<algorithm> using namespace std; const int ma ...

  7. Java 2 个 List 集合数据求并、补集操作

    开发过程中,我们可能需要对 2 个 或多个 List 集合中的数据进行处理,比如多个 List 集合数据求 相同元素,多个 List 集合数据得到只属于本身的数据,如图示: 这里写图片描述 这里以 2 ...

  8. SQL_求集合中每天最大时间记录的总和

    --问题求 集合中每天最大时间的总和 表中的数据 列: 用户 分数 时间 A 2 2014-01-01 01:00:00 A 2 2014-01-01 02:00:00 A 2 2014-01-01 ...

  9. 求给定数据中最小的K个数

    public class MinHeap { /* * * Top K个问题,求给定数据中最小的K个数 * * 最小堆解决:堆顶元素为堆中最大元素 * * * */ private int MAX_D ...

随机推荐

  1. SelectSort

    /**简单选择排序*/ #include<cstdio> #include<algorithm> using namespace std; int a[]={5,2,1,3,4 ...

  2. php 图片局部打马赛克

    php 图片局部打马赛克 原理: 对图片中选定区域的每一像素,添加若干宽度及高度,生成矩型.而每一像素的矩型重叠在一起.就形成了马赛克效果. 本例使用GD库的imagecolorat获取像素颜色,使用 ...

  3. CesiumJS - 3D Tiles BIM

    CesiumJS - 3D Tiles BIM eryar@163.com 1. Introduction CesiumJS is an open-source JavaScript library ...

  4. Eclipse上开发IBM Bluemix应用程序

    林炳文Evankaka原创作品. 转载请注明出处http://blog.csdn.net/evankaka 摘要:本文主要解说了怎样使用安装EclipseIBM Bluemix插件.并在Eclipse ...

  5. Codefroces 766D Mahmoud and a Dictionary

    D. Mahmoud and a Dictionary time limit per test 4 seconds memory limit per test 256 megabytes input ...

  6. 给网站设置ICO图标

    方法一:         直接在站点根目录下放入名为:favicon.ico 的图标文件(必须要为 ICO 文件,BMP 及其他格式的图片文件不行).还有将 favicon.ico 中的 favico ...

  7. 【记录】无法读取配置节“AppSettings”,因为它缺少节声明

    Web.config对大小写敏感, 把AppSettings改为appSettings即可.

  8. MyBatis学习总结(16)——Mybatis使用的几个建议

    1.Mapper层参数为Map,由Service层负责重载. Mapper由于机制的问题,不能重载,参数一般设置成Map,但这样会使参数变得模糊,如果想要使代码变得清晰,可以通过service层来实现 ...

  9. ajax同时请求多个服务器?

    这是地址, http://119.29.23.116/info.php 大侠你怎么看 想利用雅黑探针检测服务器的在线状态,但对AJAX多个请求不会操作 header('Access-Control-A ...

  10. actionBar-shareIcon 分享按钮的修改

    今天为了修改图库的分享按钮,进行了很多的尝试 1.寻找到了xml文件,如下 <?xml version="1.0" encoding="utf-8"?&g ...