Advertisement
Guest User

2352

a guest
Apr 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4. int main ()
  5. {
  6.     int n,m,max=0;
  7.     cout << "Введите размерность матрицы: "; cin >> n;
  8.     m=n;
  9.     int **A=new int *[n];
  10.     for (int i=0; i<n; i++)
  11.         A[i]=new int [m];
  12.     for (int i=0; i<n; i++)
  13.         delete[]A[i];
  14.     delete[]A;
  15.    
  16.     cout << "Введите элементы матрицы " << n << 'x' << m << ": " << "\n";
  17.     for (int i=0; i<n; i++)
  18.         for (int j=0; j<m; j++) {
  19.            cout << "A[" << i+1 << "][" << j+1 << "]="; cin >> A[i][j]; cout << endl;
  20.            
  21. }
  22.    
  23.     cout << "\nMatrix A" << endl;
  24.     for (int i=0; i<n; i++) {
  25.         for(int j=0; j<m; j++)
  26.             cout << A[i][j] << " ";
  27.         cout << endl;
  28.     }
  29.    
  30.     cout << endl;
  31.     for (int i=0; i<n; i++) {
  32.         for (int j=0; j<m; j++) {
  33.             cout << A[i][j] << " ";
  34.         cout << endl;
  35.         }
  36.     }
  37.    
  38.     for (int i=0; i<n; i++)
  39.         for (int j=0; j<m; j++) {
  40.         if (A[i][j] > max) {
  41.             max = A[i][j];
  42.         }
  43.     }
  44.     cout << "Максимальный элемент в заданном промежутке = " << max << endl;
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement