1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
dezoksy [38]
3 years ago
12

This program builds on the program developed in part

Computers and Technology
1 answer:
soldi70 [24.7K]3 years ago
8 0

Answer:

The solution is in C++

Explanation:

// C++ programs to search a word in a 2D grid  

#include<bits/stdc++.h>  

using namespace std;  

// Rows and columns in given grid  

#define R 3  

#define C 14  

// For searching in all 8 direction  

int x[] = { -1, -1, -1, 0, 0, 1, 1, 1 };  

int y[] = { -1, 0, 1, -1, 1, -1, 0, 1 };  

// This function searches in all 8-direction from point  

// (row, col) in grid[][]  

bool search2D(char grid[R][C], int row, int col, string word)  

{  

// If first character of word doesn't match with  

// given starting point in grid.  

if (grid[row][col] != word[0])  

return false;  

int len = word.length();  

// Search word in all 8 directions starting from (row,col)  

for (int dir = 0; dir < 8; dir++)  

{  

 // Initialize starting point for current direction  

 int k, rd = row + x[dir], cd = col + y[dir];  

 // First character is already checked, match remaining  

 // characters  

 for (k = 1; k < len; k++)  

 {  

  // If out of bound break  

  if (rd >= R || rd < 0 || cd >= C || cd < 0)  

   break;  

  // If not matched, break  

  if (grid[rd][cd] != word[k])  

   break;  

  // Moving in particular direction  

  rd += x[dir], cd += y[dir];  

 }  

 // If all character matched, then value of must  

 // be equal to length of word  

 if (k == len)  

  return true;  

}  

return false;  

}  

// Searches given word in a given matrix in all 8 directions  

void patternSearch(char grid[R][C], string word)  

{  

// Consider every point as starting point and search  

// given word  

for (int row = 0; row < R; row++)  

for (int col = 0; col < C; col++)  

 if (search2D(grid, row, col, word))  

  cout << "pattern found at " << row << ", "

   << col << endl;  

}  

// Driver program  

int main()  

{  

char grid[R][C] = {"GEEKSFORGEEKS",  

    "GEEKSQUIZGEEK",  

    "IDEQAPRACTICE"

    };  

patternSearch(grid, "GEEKS");  

cout << endl;  

patternSearch(grid, "EEE");  

return 0;  

}  

You might be interested in
What does the hot end of a 3D printer do?
Alex Ar [27]

Answer:

The hot end is where the heated filament comes out and moves across the print bed to create your 3D object! ... Different materials may print best at different temperatures so the sensor is important and it's temperature can be set with your slicing program.

Explanation:

7 0
3 years ago
What is a graphics card and what does it do?
prisoha [69]
Its basically a chip in a computer microprocessor, it allows the microprocessor to work at full speed. it also hamdles video calculation within the computer.
6 0
4 years ago
Read 2 more answers
Which element adds a “page turn” effect to the slides in a presentation?
garri49 [273]

Answer:

D. Slide Transition

Explanation:

Hope this help you

3 0
3 years ago
Read 2 more answers
Servers that manage only one type of resource are called ____ servers.
Nataly [62]

Answer: Motherboard i tuink

Explanation:

3 0
3 years ago
To adjust the height or width to fit the dialog within it, you should use these options. Click all that apply
Blizzard [7]

Answer: manually drag the box to adjust the cell

Double-click the cell to adjust to largest size needed

In the Home tab’s Cells feature, select cell size.

Explanation:

I took the test.

8 0
4 years ago
Read 2 more answers
Other questions:
  • In 2-5 paragraphs, describe the points that Kendra needs to consider when choosing a telecommunications technology to meet her n
    6·1 answer
  • What is a lease? AA contract outlining the terms of a mortgage. BA contract outlining the terms under which a landlord agrees to
    15·1 answer
  • ) Consider the ambiguous CFG problem: given a context free grammar, does there exist a string that can be generated by two diffe
    5·1 answer
  • How to hard reset a iphone 7 without computer
    8·2 answers
  • Mario wants to use computer.what is the first thing needs to know<br><br>​
    6·1 answer
  • True or False?Only flying unmanned aircraft over 20lbs requires preparation and safety calculations.
    8·1 answer
  • what are the benefits of VolP? select all that apply. A:cheaper printings B:clearer calls C: faster download D: increased effici
    11·2 answers
  • What is the output of the code?
    15·1 answer
  • Instructions
    8·1 answer
  • When you start a new, blank document, you usually end up changing the font to arial 11. 5 point. How can you make these settings
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!