Advertisement
alexdmin

aue_vsem

Jun 27th, 2021
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.49 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void inputArray(int** arr, int N)
  5. {
  6.     cout << "Введите элементы массива A " << endl;
  7.     for (int i = 0; i < N; i++)
  8.     {
  9.         for (int j = 0; j < N; j++)
  10.         {
  11.             cout << "A[" << i+1 << "][" << j+1 << "]=";
  12.             cin >> arr[i][j];
  13.         }
  14.     }
  15. }
  16. void OutputArray(int** arr, int N)
  17. {
  18.     cout << "Полученная матрица размера " << N << "x" << N << endl;
  19.     for (int i = 0; i < N; i++)
  20.     {
  21.         for (int j = 0; j < N; j++)
  22.         {
  23.             cout << arr[i][j] << " ";
  24.         }
  25.         cout << endl;
  26.     }
  27.     cout << endl;
  28. }
  29. void SortArray(int** arr, int N)
  30. {
  31.     int max = 0;
  32.     int i = 0, j = 0;
  33.     int find = 0;
  34.     max = arr[0][0];
  35.     for (int i = 0; i < N; i++)
  36.         for (int j = 0; j < N; j++)
  37.             if (max < arr[i][j])
  38.             {
  39.                 max = arr[i][j];
  40.                 find = i + 1;
  41.             }
  42.     cout << "Максимальный элемент равен " << max << " В строке № " << find << endl;
  43. }
  44.  
  45. int main()
  46. {
  47.     setlocale(LC_ALL, "rus");
  48.     cout << "Введите размерность квадратной матрицы N\n";
  49.     int N = 0;
  50.     cin >> N;
  51.     int** dinamic_array = new int* [N];
  52.     for (int i = 0; i < N; i++)
  53.     {
  54.         dinamic_array[i] = new int[N];
  55.     }
  56.     inputArray(dinamic_array, N);
  57.     OutputArray(dinamic_array, N);
  58.     SortArray(dinamic_array, N);
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement