Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C Code - 2D Array, Sorting Skeleton Code: // search_pattern.c #include #define MINE '*' // a mine-filled square #define FIELD_ROWS 8 // number of rows
C Code - 2D Array, Sorting
Skeleton Code:
// search_pattern.c #include#define MINE '*' // a mine-filled square #define FIELD_ROWS 8 // number of rows for minefield #define FIELD_COLS 8 // number of columns for minefield #define PAT_ROWS 2 // number of rows for pattern #define PAT_COLS 3 // number of columns for pattern void scan_mines(char [][FIELD_COLS+1]); void scan_pattern(char [][PAT_COLS]); void print_minefield(char [][FIELD_COLS+1]); void print_pattern(char [][PAT_COLS]); int search(char [][FIELD_COLS+1], char [][PAT_COLS]); int main(void) { char minefield[FIELD_ROWS][FIELD_COLS+1]; char pattern[PAT_ROWS][PAT_COLS]; printf("Enter minefield: "); scan_mines(minefield); printf("Minefield entered: "); print_minefield(minefield); printf("Enter search pattern: "); scan_pattern(pattern); printf("Search pattern entered: "); print_pattern(pattern); printf("Answer = %d ", search(minefield, pattern)); return 0; } // Read the grid for minefield void scan_mines(char grid[][FIELD_COLS+1]) { int r; for (r=0; r
Test Data: http://www.comp.nus.edu.sg/~cs1010/practice/2017s1/Practice-S12P04/testdata/
Objective: 2D array, searching Task statement Assuming that you have an 8x8 minefield and a 2x3 pattern. You are to write a program search_pattern.c to count the number of times the pattern appears in the minefield Sample runs: Enter minefield: Minefield entered: - --- ---- --- Enter search pattern: Search pattern entered: Answer 4
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started