AlexandrTalchuk

5.2.11

Dec 29th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1.  
  2.  
  3. #include "pch.h"
  4. #include <iostream>
  5. using namespace std;
  6.  
  7.  
  8. int main()
  9. {
  10.     setlocale(LC_ALL, ("RUS"));
  11.     int **arr, n, m, i, j, k=0;
  12.  
  13.     cout << "Введите количество строк" << endl;
  14.     cin >> n;
  15.     cout << "Введите количество столбцов" << endl;
  16.     cin >> m;
  17.  
  18.     arr = new int *[n];
  19.         for (i = 0; i < n; i++)
  20.     arr[i] = new int[m];
  21.  
  22.     for (i = 0; i < n; i++) {
  23.         for (j = 0; j < m; j++)
  24.         {
  25.             cout << "a[" << i + 1 << "][" << j + 1 << "]=";
  26.             cin >> arr[i][j];
  27.  
  28.         }
  29.     }
  30.     for (i = 0; i < n; i++)
  31.     {
  32.         for (j = 1; j < m-1; j++)
  33.         {
  34.            
  35.                 if (arr[i][j - 1]<arr[i][j] && arr[i][j + 1]>arr[i][j])
  36.                     k++;
  37.            
  38.         }
  39.     }
  40.     cout << "Всего " << k <<" элементов" << endl;
  41.  
  42.     for (i = 0; i < n; i++)
  43.         delete[]arr[i];
  44.     delete[]arr;
  45.  
  46.     system("pause");
  47.     return 0;
  48.  
  49. }
Add Comment
Please, Sign In to add comment