Created
August 11, 2021 16:08
-
-
Save modos/cb027880f1e5a09306a2e5354c357404 to your computer and use it in GitHub Desktop.
زینی
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************************************************** | |
Online C++ Compiler. | |
Code, Compile, Run and Debug C++ program online. | |
Write your code in this editor and press "Run" button to compile and execute it. | |
*******************************************************************************/ | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
int n; | |
int m; | |
cin >> n; | |
cin >> m; | |
int a[n][m]; | |
int sum = 0; | |
for (int i = 0; i < n; i++) { | |
for (int j = 0; j < m; j++) { | |
cin >> a[i][j]; | |
} | |
} | |
for (int i = 1; i < n - 1; i++) { | |
for (int j = 1; j < m - 1; j++) { | |
if ((a[i][j] < a[i - 1][j] && a[i][j] < a[i + 1][j] && a[i][j] > a[i][j - 1] && a[i][j] > a[i][j + 1]) || | |
(a[i][j] > a[i - 1][j] && a[i][j] > a[i + 1][j] && a[i][j] < a[i][j - 1] && a[i][j] < a[i][j + 1])){ | |
sum = sum + 1; | |
} | |
} | |
} | |
cout << sum; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment