Generation

generate functionThu, 08 Dec 2022

find where 3 or more of the same value integers are adjacent to each other in a 2D array.

int checkAdjacent(int arr[10][10], int row, int col) { int i, j; int count = 1; for (i = 0; i < row; i++) { for (j = 1; j < col; j++) { if (arr[i][j] == arr[i][j - 1]) { count++; } else { count = 1; } if (count == 3) { return 1; } } } for (j = 0; j < col; j++) { for (i = 1; i < row; i++) { if (arr[i][j] == arr[i - 1][j]) { count++; } else { count = 1; } if (count == 3) { return 1; } } } return 0; }

Want to kickstart your project?Use the new AI Studio to create your code