Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, x;
- double summ = 0,sum2 = 0;
- double mx = 0,dx = 0;
- cin >> n;
- for (int i = 1; i <= n; i++)
- {
- x = rand() % 10;
- cout << " x : " << x;
- summ += x;
- if ( i == n)
- {
- mx += summ / n;
- }
- for (int j = 1; j <= i; j++)
- {
- sum2 += mx * mx - 2*x * mx + x*x;
- if (j == i) {
- dx = sum2 / n;
- }
- }
- }
- cout << "\ndx : " << dx << " mx : " << mx;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement