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
When powering up a home network, make sure all computers and peripherals are turned on before turning on the modem/router?
vazorg [7]
<span>the statement that when powering up a home network, make sure all computers and peripherals are turned on before turning on the modem/router is false.
The network devices like computers and other peripherals do not have to turned on before turning on the modem, they can be also later turned on.</span>
4 0
3 years ago
Which of the following is a camera problem that dirt can cause?
makkiz [27]

Answer:

all of the above

Explanation:

hope this helps:)

4 0
3 years ago
Read 2 more answers
Suppose h(m) is a collision-resistant hash function that maps a message of arbitrary bit length into an n-bit hash value. is it
Korolek [52]

That can't be true. Collision resistant just means the chance is really low, but not 0. Suppose you enumerate all possible hash values with each their different original message. Since the message length can be larger than n, you can then find a message whose hash is already in the list, ie., a collision!

5 0
3 years ago
After you enter a formula and press enter, you see #DIV/0!. This means _____.
Travka [436]
The error message gives it away "#DIV/0!". A division by zero error has occurred, and and error is displayed because dividing by zero is mathematically impossible.
3 0
3 years ago
To check whether your writing is clear , you can
Bezzdna [24]

Answer: Hi!, hope this helps. :)

Explanation: After you proofread and do a first edit of you paper, you should either read it out loud or have someone read it back to you. Hearing the paper out loud is one of the best ways to find unclear wordings. You should also do revising. You should make sure your writing meets the requirements of the writing catagory and maybe even get a rubric of the requirements.

This is the best answer I can give, I hope this answers your question! Try to make me the brainliest if you can.

3 0
4 years ago
Read 2 more answers
Other questions:
  • Andy uses a dial-up modem to connect to the Internet. He usually browses news sites, but he notices that online video takes a lo
    15·1 answer
  • In the ADT graph the methid addVertex has efficiency
    15·1 answer
  • Write a program to enter a number and test if it is greater than 45.6.if the number entered is greater than 45.6 the program nee
    13·1 answer
  • Excel can display characters in only three font colors: black, red, and blue. (points : 2) true false
    11·1 answer
  • A common practice is to create a(n) _____ on any field that is used as a search key, in comparison operations in a conditional e
    6·1 answer
  • Which of the following is an accurate definition of a computer system? A computer system consists of the operating system that t
    6·1 answer
  • A chief Information Security Officer (CISO) is performing a BIA for the organization in case of a natural disaster. Which of the
    8·1 answer
  • Briefly explain what an array is. As part of your answer make use of a labelled example to show the declaration and components o
    5·1 answer
  • The picture above is a description of the C code below. Please modify the C below so that it uses FILE HANDLING (fopen, fputs, f
    5·1 answer
  • A related database stores data in the form of______
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!