-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcavity_map.cpp
More file actions
34 lines (32 loc) · 749 Bytes
/
cavity_map.cpp
File metadata and controls
34 lines (32 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, i, j;
scanf("%d", &n);
int a[n][n];
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
scanf("%1d", &a[i][j]);
}
}
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
if ((i >= 1) && (i < n - 1) && (j >= 1) && (j < n - 1))
{
if ((a[i][j] > a[i - 1][j]) && (a[i][j] > a[i][j + 1]) && (a[i][j] > a[i + 1][j]) && (a[i][j] > a[i][j - 1]))
printf("X");
else
printf("%d", a[i][j]);
}
else
printf("%d", a[i][j]);
}
printf("\n");
}
return 0;
}