Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- #include <time.h>
- using namespace std;
- int main() {
- const int n = 4;
- int a[n][n], b[n * n / 2], k = 0;
- srand(time(NULL));
- for (int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- a[i][j] = rand() % 10 - 2;
- cout << a[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl;
- for (int i = 0; i < n; i++) {
- int max = a[i][0];
- for(int j = 1; j < n; j++)
- if (a[i][j] > max)
- max = a[i][j];
- a[0][i] = max;
- }
- for (int i = 0; i < n; i++)
- cout << a[0][i] << " ";
- cout << endl;
- int s = 0;
- for(int i = 0; i < n; i++)
- s += a[0][i] * a[0][n - i - 1];
- cout << endl << s;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement