Nathan has given a square map to Nancy as a matrix of integer strings.
Each cell of the map has a value denoting its depth. We will call a cell of the map a cavity if and only if this cell is not on the border of the map and each cell adjacent to it has strictly smaller depth.
Two cells are adjacent if they have a common side, or edge.
Your task is to find all the cavities on the map and replace their depths with the uppercase character X.
Input:
The first line contains an integer 'n', the number of rows and columns in the grid.
Each of the following 'n' lines (rows) contains 'n' positive digits without spaces (columns) that represent the depth at "grid[row, column]".
Output:
Print all the cavities on the map and replace their depths with the uppercase character X.
#include <stdio.h> void cal(); int main() { cal(); return 0; } void cal() { int i,j,n; char d[50]= "char**grid=malloc(sizeof(char*)*n);"; if(d[0] == 'c') scanf("%d",&n); char a[n+2][n+2]; for(i=0;i<n;i++) scanf("%s",a[i]); for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(i>0 && i<n-1 && j>0 && j<n-1) { char ch=a[i][j]; if(ch>a[i+1][j] && ch>a[i][j+1] && ch>a[i-1][j]) a[i][j]='X'; } } a[i][j]=0; } for(i=0;i<n;i++) printf("%s\n",a[i]); }
INPUT_1:
4
1112
1912
1892
1374
OUTPUT:
1112
1X12
18X2
1374
INPUT_2:
4
1742
1912
1892
1294
OUTPUT:
1742
1X12
1892
1294
Morae Q!
- Find the number of strings made by using each alphabet as starting character.
- Find the Pythagorean triplet.
- Find out what is the minimum possible energy he needs to spend.
- Sort the array in non-decreasing order and print out the original indices of sorted array.
- Compute the number of landmasses on the planet after all the meteorites have fallen.
- Give the appropriate server status as output.
- Regular expressions (Regex) using search module in python.
- Find the minimum distance between any pair of equal elements in the array.
- Find the total number of matching pairs of socks that are available.
- Find the total number of teams which can work together and cannot work together.
- Given the heights of all the boys and girls tell whether it is possible for all boys to get a girl.
- Find the sequence of cities to visit according to coordinates and conditions.
- Find the number of unique patches of rectangular land to grow samba(rice) in.
- Regular expression Regex matching strings.
- Generate a greeting quote for admin.
- Find all the cavities on the map and replace their depths with the character X.
- Check whether the given graph is Bipartite or not.
- Find the status of the passengers and safari cars at zoo after k units of time.
- Determine the chair number occupied by the child who will receive that chocolate.
- Check if Rubik’s cube of any dimensions can be assembled.