Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, ("RUS"));
- int **arr, n, m, i, j, k=0;
- cout << "Введите количество строк" << endl;
- cin >> n;
- cout << "Введите количество столбцов" << endl;
- cin >> m;
- arr = new int *[n];
- for (i = 0; i < n; i++)
- arr[i] = new int[m];
- for (i = 0; i < n; i++) {
- for (j = 0; j < m; j++)
- {
- cout << "a[" << i + 1 << "][" << j + 1 << "]=";
- cin >> arr[i][j];
- }
- }
- for (i = 0; i < n; i++)
- {
- for (j = 1; j < m-1; j++)
- {
- if (arr[i][j - 1]<arr[i][j] && arr[i][j + 1]>arr[i][j])
- k++;
- }
- }
- cout << "Всего " << k <<" элементов" << endl;
- for (i = 0; i < n; i++)
- delete[]arr[i];
- delete[]arr;
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment