Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<ctime>
- #include<iomanip>
- using namespace std;
- void Fillingmatrix(int** arr, int rows, int cols)
- {
- srand(time(NULL));
- arr = new int* [rows];
- for (int d = 0; d < rows; d++)
- {
- arr[rows] = new int[cols];
- }
- for (int k = 0; k < rows; k++)
- for (int p = 0; p < cols; p++)
- {
- arr[rows][cols] = rand() % 20;
- }
- }
- void maintask(int** arr, int rows, int cols)
- {
- Fillingmatrix(arr, rows, cols);
- int max = arr[0][0];
- int rowsindex = 0;
- int colsindex = 0;
- for (int i = 0; i < rows; i++)
- for (int j = 0; j < cols; j++)
- {
- if (arr[i][j] > max)
- {
- max = arr[i][j];
- rowsindex = i;
- colsindex = j;
- }
- }
- cout << "The biggest element in " << arr << "array is " << max << endl;
- for (int i = 0; i < rows; i++)
- for (int j = 0; j < cols; j++)
- {
- if (i = rowsindex, j = colsindex)
- {
- arr[i][j] = 1;
- }
- }
- }
- void matrixcout(int** arr, int rows, int cols)
- {
- maintask(arr, rows, cols);
- for (int k = 0; k < rows; k++)
- for (int u = 0; u < cols; u++)
- {
- cout << setw(rows) << arr[k][u];
- }
- }
- int main()
- {
- int rows = 5;
- int cols = 5;
- int** A = new int* [rows];
- int** Y = new int* [rows];
- Fillingmatrix(A, 6, 3);
- Fillingmatrix(Y, 4, 5);
- maintask(A, 6, 3);
- maintask(Y, 4, 5);
- matrixcout(A, 6, 3);
- matrixcout(Y, 4, 5);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement