Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program written in C++ Write a program that searches for specified words hidden within a matrix of letters Read a file that the user specifies.

Program written in C++

image text in transcribed

Write a program that searches for specified words hidden within a matrix of letters Read a file that the user specifies. The file will first specify the dimensions of the matrix (eg., 20 30). These two numbers specify the number of rows in the matrix and then the number of columns in the matrix. Following these two numbers, there will be a number of rows of letters. These letters should be read into your matrix row by row, column by column. Following the rows of letters, there will be some number of words that might be hidden within the matrix. You are to search for these words and report 1) whether or not a given word is found within the matrix, and if so, the starting and ending matrix coordinates of the word 4. Search for each word one at a time (i.e., read a word, search for it, report the results, and thern read the next word from the file). Continue until all words have been searched for Start by creating your own file of data. You can start with a small matrix size and your owrn hidden words. When you're ready, start testing one or more of the files I'm going to upload for your use To test your program, I suggest searching for the first 4 letters in the top row, then the first 4 letters in the leftmost (first) column, and then the first 4 letters starting from position [O][O] down the diagonal to the right and down. That will let you know if you are traversing the matrix properly Provide for fault-tolerance when trying to open the input file. If it doesn't exist or can't be found, tell the user. Also, tell the user the name of the file that can't be found/opened. Then give the user a chance to enter another file name and try to open that file. Continue until you either find and open the file or until the user types something like "quit" or "exit." If you feel comfortable doing so, use the perror function to report the system's error message; then report your own errormessages. Make sure your program can handle bad file names and/or non-existent files Don'treport success or failure for each word as you go. Instead, report only words that are found; but for words that are not found, shove them into a vector of strings and wait until you've searched for all words before reporting the words that weren't found. Thus, you will have all successfully found words appearfirst-along with theircoordinates and (optionally) their direction--and then the words that weren't found will be listed at the end Assume that words can appear more than once in the matrix 6

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions