Advertisement
AndreyKlipikov

[Olegu] Prog. Lab7. N26

Dec 25th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 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], b[n * n / 2], k = 0;
  10.     srand(time(NULL));
  11.     for (int i = 0; i < n; i++) {
  12.             for(int j = 0; j < n; j++) {
  13.                     a[i][j] = rand() % 10 - 2;
  14.                     cout << a[i][j] << " ";
  15.             }
  16.             cout << endl;
  17.     }
  18.  
  19.     cout << endl;
  20.  
  21.     for (int i = 0; i < n; i++) {
  22.             int max = a[i][0];
  23.             for(int j = 1; j < n; j++)
  24.                     if (a[i][j] > max)
  25.                         max = a[i][j];
  26.             a[0][i] = max;
  27.     }
  28.  
  29.     for (int i = 0; i < n; i++)
  30.         cout << a[0][i] << " ";
  31.  
  32.     cout << endl;
  33.    
  34.     int s = 0;
  35.     for(int i = 0; i < n; i++)
  36.         s += a[0][i] * a[0][n - i - 1];
  37.  
  38.     cout << endl << s;
  39.  
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement