Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n, x;
  8.     double summ = 0,sum2 = 0;
  9.     double mx = 0,dx = 0;
  10.     cin >> n;
  11.     for (int i = 1; i <= n; i++)
  12.     {  
  13.         x = rand() % 10;
  14.         cout << " x : " << x;
  15.         summ += x;
  16.         if ( i == n)
  17.         {
  18.             mx += summ / n;
  19.            
  20.         }
  21.         for (int j = 1; j <= i; j++)
  22.         {
  23.             sum2 += mx * mx - 2*x * mx + x*x;
  24.             if (j == i) {
  25.                 dx = sum2 / n;
  26.             }
  27.         }
  28.     }
  29.     cout << "\ndx : " << dx << " mx : " << mx;
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement