AndreyKlipikov

[Niyaz] Prog. Tikket N10. 1

Dec 30th, 2013
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <time.h>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     const int n = 4;
  9.     int a[n][n];
  10.     double b[n];
  11.     srand(time(NULL));
  12.  
  13.     for (int i = 0; i < n; i++) {
  14.             for(int j = 0; j < n; j++) {
  15.                     a[i][j] = rand() % 10 - 2;
  16.                     cout << a[i][j] << " ";
  17.             }
  18.             cout << endl;
  19.     }
  20.     cout << endl;
  21.  
  22.     for (int i = 0; i < n; i++) {
  23.             double s = 0;
  24.             for(int j = 0; j < n; j++)
  25.                     s += a[i][j];
  26.             b[i] = s / n;
  27.     }
  28.  
  29.     cout << endl;
  30.  
  31.     cout.precision(4);
  32.     for (int i = 0; i < n; i++)
  33.         cout << b[i] << " ";
  34.     cout << endl;
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment