Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include<conio.h>
- #include<cctype>
- using namespace std;
- int MaxElement(int** mas, int n) {
- int max, i, j;
- max = mas[0][0];
- for (i = 0; i < n; i++)
- {
- for (j = 0; j < n; j++)
- {
- if (mas[i][j] > max)
- {
- max = mas[i][j];
- }
- }
- }
- return max;
- }
- void Rand(int** mas, int n) {
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- mas[i][j] = rand() % 50 + 1;
- }
- }
- }
- void Show(int** mas, int n) {
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- cout << mas[i][j] << "\t";
- }
- cout << "\n";
- }
- }
- void main()
- {
- setlocale(LC_ALL, "ukr");
- int n = 5, max;
- int q = 0, w, e, i, j;
- e = 0;
- int** mas1 = new int* [n];
- for (int i = 0; i < n; i++)
- mas1[i] = new int[n];
- int** mas2 = new int* [n];
- for (int i = 0; i < n; i++)
- mas2[i] = new int[n];
- Rand(mas1, n);
- Rand(mas2, n);
- cout << "Масив №1:" << endl;
- Show(mas1, n);
- cout << "Масив №2:" << endl;
- Show(mas2, n);
- cout << "--------------------------\n";
- cout << "\nПiвсума найбiльших елементiв: " << (MaxElement(mas1, n) + MaxElement(mas2, n)) / 2 << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment