SHARE
TWEET

Code

MykytaAtP1 Nov 19th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include<ctime>
  3. #include<iomanip>
  4. using namespace std;
  5. void Fillingmatrix(int** arr, int rows, int cols)
  6. {
  7.     srand(time(NULL));
  8.     arr = new int* [rows];
  9.     for (int d = 0; d < rows; d++)
  10.     {
  11.         arr[rows] = new int[cols];
  12.     }
  13.     for (int k = 0; k < rows; k++)
  14.         for (int p = 0; p < cols; p++)
  15.         {
  16.             arr[rows][cols] = rand() % 20;
  17.         }
  18. }
  19. void maintask(int** arr, int rows, int cols)
  20. {
  21.     Fillingmatrix(arr, rows, cols);
  22.     int max = arr[0][0];
  23.     int rowsindex = 0;
  24.     int colsindex = 0;
  25.     for (int i = 0; i < rows; i++)
  26.         for (int j = 0; j < cols; j++)
  27.         {
  28.             if (arr[i][j] > max)
  29.             {
  30.                 max = arr[i][j];
  31.                 rowsindex = i;
  32.                 colsindex = j;
  33.             }
  34.         }
  35.     cout << "The biggest element in " << arr << "array is " << max << endl;
  36.     for (int i = 0; i < rows; i++)
  37.         for (int j = 0; j < cols; j++)
  38.         {
  39.             if (i = rowsindex, j = colsindex)
  40.             {
  41.                 arr[i][j] = 1;
  42.             }
  43.         }
  44. }
  45. void matrixcout(int** arr, int rows, int cols)
  46. {
  47.     maintask(arr, rows, cols);
  48.     for (int k = 0; k < rows; k++)
  49.         for (int u = 0; u < cols; u++)
  50.         {
  51.             cout << setw(rows) << arr[k][u];
  52.         }
  53. }
  54. int main()
  55. {
  56.     int rows = 5;
  57.     int cols = 5;
  58.     int** A = new int* [rows];
  59.     int** Y = new int* [rows];
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.     Fillingmatrix(A, 6, 3);
  72.     Fillingmatrix(Y, 4, 5);
  73.     maintask(A, 6, 3);
  74.     maintask(Y, 4, 5);
  75.     matrixcout(A, 6, 3);
  76.     matrixcout(Y, 4, 5);
  77.     system("pause");
  78.     return 0;
  79. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top