Advertisement
Guest User

10-th

a guest
Feb 22nd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "Windows.h"
  3. #include "stdio.h"
  4. #include "time.h"
  5. #include <iostream>
  6. using namespace std;
  7.  
  8.  
  9. int main()
  10. {
  11.     srand(time(0));
  12.     SetConsoleCP(1251);
  13.     SetConsoleOutputCP(1251);
  14.  
  15.     int const N = 10;
  16.     int const M = 10;
  17.  
  18.     int arrx2[N][M];
  19.     int arrx2Dev[N][M];
  20.     int cy1, cy2,sum = 0, E;
  21.  
  22.     for (cy1 = 0; cy1 < N; cy1++) // Генерация основного цикла
  23.     {
  24.         for (cy2 = 0; cy2 < M; cy2++)
  25.         {
  26.             arrx2[cy1][cy2] = rand() % 51 -25;
  27.             cout << arrx2[cy1][cy2] << "\t";
  28.             sum += arrx2[cy1][cy2]; //Подсчет суммы всех елементов
  29.         }
  30.         cout<<endl;
  31.     }
  32.     cout << "\n___________________________________\n";
  33.     E = sum / (N*M); // Е = Ср. арифметическое
  34.     cout << "Среднее арифметическое = " << E << endl;
  35.     cout << "\n___________________________________\n";
  36.     for (cy1 = 0; cy1 < N; cy1++) //Рассчет отклонений. Значения отклонения записываются во второй цикл
  37.     {
  38.         for (cy2 = 0; cy2 < M; cy2++)
  39.         {
  40.             arrx2Dev[cy1][cy2] = E - arrx2[cy1][cy2]; //Среднее арифметическое минус елемент
  41.             cout << arrx2Dev[cy1][cy2] << "\t";
  42.         }
  43.         cout << endl;
  44.     }
  45.     cout << "\n___________________________________\n";
  46.  
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement