Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that searches for specified words hidden within a matrix of letters. 1. Read a file that the user specifies. The file will

Write a program that searches for specified words hidden within a matrix of letters.

1. Read a file that the user specifies. The file will first specify the dimensions of the matrix (e.g., 20 30). These two numbers specify the number of rows in the matrix and then the number of columns in the matrix.

2. 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.

3. 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 then read the next word from the file). Continue until all words have been searched for.

5. Start by creating your own file of data. You can start with a small matrix size and your own hidden words. When youre ready, start testing one or more of the files Im going to upload for your use.

6. 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 [0][0] down the diagonal to the right and down. That will let you know if you are traversing the matrix properly.

7. Provide for fault-tolerance when trying to open the input file. If it doesnt exist or cant be found, tell the user. Also, tell the user the name of the file that cant 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 systems error message; then report your own error messages. Make sure your program can handle bad file names and/or non-existent files.

8. Dont report 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 youve searched for all words before reporting the words that werent found. Thus, you will have all successfully found words appear first -- along with their coordinates and (optionally) their direction -- and then the words that werent found will be listed at the end.

9. Assume that words can appear more than once in the matrix.

10. Dont worry about wrapping around the edges of the matrix. Instead, if you hit an edge while searching, assume the word isnt in the matrix.

11. For extra fun, consider adding an interactive capability to your program that asks the user to enter additional words to search for in the matrix once youve searched for all words in the data file.

Annotations for the code:

1. The main function can be at either the beginning or the end of the program. I dont care which.

2. Add comments at the top of your program file to include your name, the name of the program, and any relevant notes on how your design works when executed.

3. Add a change log in your comments that list the major changes you make to your logic and when nothing too terribly detailed, but a list of breadcrumbs that will remind you and others of what youve done as your program becomes more sophisticated and/or nearly complete.

4. Point out (in the comments at the top of your program) any special features or techniques you added using a comment saying something like // Special Features:

5. Comment your code effectively, as we discussed in class. Use descriptive variable names everywhere so that the code becomes as self-documenting as possible. Use additional commentary only to improve readability and comprehensibility by other people.

6. You absolutely MUST use consistent indentation and coding styles throughout the program. Failure to do so will result in a loss of three points.

7. If the program does not work at all, or works incorrectly, at least 10 points will be deducted.

8. No late submissions will be accepted. Please meet the deadline.

ComedyMovies.txt :

15 18 SCFRBOBROBERTSLOKL TNLESREKCILSYTICRL AOEPOBLRUAECHBUDEA RITOTHEYOMTOLBATPH LCHAIBAONILLAURGEI AEKNLULDDGCISLHKLN CRRURDBHSAGTEOPLUS LOTCLULHLLBPCRAPLA UMSKIROPOULALPEAAK EHNSAHNNSTLASACCEH LSOORADTEHSHBKCROA EUOUFMEMECOHETHEER SRMPARTRBTAROSAASV SLEISTOOTHERUTLESE NATTAHNAMSEYSLSSMY

ALLOFME ANNIEHALL BABE BEINGTHERE BIG BOBROBERTS BULLDURHAM CARS CATBALLOU CITYSLICKERS MEATBALLS

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

Recommended Textbook for

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions