Advertisement
Aleksandr_Grigoryev

HW 2.3

Nov 22nd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {  
  5.     const int n=5;
  6.     int a[n]={1,2,3,4,5},i,sum=0,sum1=0,r;
  7.     double m,u,t;
  8. for (i=0;i<n;i++)
  9. {
  10.     sum=a[i]+sum;
  11.     u=(1/(double)n)*sum;
  12.    
  13. }
  14. for (int r=2;r<=4;r++)
  15. {  
  16.     for (i=0;i<n;i++)
  17.     {
  18.     t=(a[i]-u);
  19.     t=t*t;
  20.     sum1=sum1+t;
  21.     }
  22.     m=(1/(double)(n))*sum1;
  23.     cout << r <<'=' << m << ' ' << endl;
  24. }
  25. system("pause");
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement