Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication 3.2(B).cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- #include <iomanip>
- #include <stdlib.h>
- #include <iostream>
- #define size 5
- using namespace std;
- void Random(int a[size][size]);
- void View(int a[size][size]);
- int Max(int arr[size][size]);
- void New(int arr[size][size], int max);
- int main()
- {
- int i = 0, j = 0, g, k, c = 0;
- int a[size][size], b[size][size];
- Random(a);
- View(a);
- New(b, Max(a));
- View(b);
- system("pause");
- return 0;
- }
- void Random(int a[size][size])
- {
- int i, j, m, n;
- do
- {
- cout << "enter m and n:\n";
- cin >> m >> n;
- } while (m >= n);
- srand(time(NULL));
- for (i = 0; i < size; i++)
- {
- for (j = 0; j < size; j++)
- {
- a[i][j] = rand() % (n - m + 1) + m;
- }
- }
- }
- void View(int a[size][size])
- {
- int i, j;
- for (i = 0; i < size; i++)
- {
- for (j = 0; j < size; j++)
- {
- cout << setw(3) << a[i][j];
- }
- cout << endl;
- }
- }
- int Max(int arr[size][size])
- {
- int arr_max = arr[0][0];
- for (int i = 0; i < 3; i++)
- {
- for (int j = 0; j < 3; j++)
- {
- if (arr[i][j] > arr_max)
- {
- arr_max = arr[i][j];
- }
- }
- cout << endl;
- }
- return arr_max;
- }
- void New(int arr[size][size], int max)
- {
- for (int i = 0; i < size; i++)
- {
- for (int j = 0; j < size; j++)
- {
- arr[i][j] = max;
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement