#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
double sum(vector<double> a)
{
double s = 0;
for (int i = 0; i < a.size(); i++)
{
s += a[i];
}
return s;
}
double sqsum(vector<double> a)
{
double s = 0;
for (int i = 0; i < a.size(); i++)
{
s += pow(a[i],2);
}
return s;
}
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int N;
cin >> N;
vector<double> nums(N);
for (int i = 0; i < nums.size(); i++)
{
cin >> nums[i];
}
cout << fixed << setprecision(1) << pow(sqsum(nums) / N - pow(sum(nums) / N, 2), 0.5);
return 0;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.