Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- // [1/(1-n)] * x2 - [1/(n(n-1))] * (x^2)
- int main () {
- cout.setf(ios::fixed);
- cout.precision(2);
- double n, x, x1, x2;
- cin >> n;
- x=0;
- x1=0;
- x2=0;
- while (cin >> x) {
- x1 += x;
- x2 += (x*x);
- }
- x1 = (x1*x1)/(n*(n-1));
- x2 /= (n-1);
- cout << (x2-x1) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment