CS 100 Project Five – Spring 2019


CS 100 Project Five – Spring 2019
Project Overview: In this project, you will write a program to solve a simple word search puzzle. The puzzle will
be saved in a file, and the filename will be provided as a command-line argument to the program. The program will
first read in a puzzle, and then it will repeatedly ask for a word to be searched until the user enters CTRL-D. For
each word, the program will search for its existence in all eight directions as shown below and report the search
results.
Northward, bottom-to-top
Southward, top-to-bottom
Eastward, left-to-right
Westward, right-to-left
Northeastward
Southeastward
Southwestward
Northwestward
As an example, consider a 5x5 puzzle saved in a file named data1, as shown below.
The following shows the result of executing ./a.out data1, when the user is searching for the word cat.
The word puzzle is:
ptati
doaac
orice
goana
etact
Enter a word to search in the puzzle (or CRTL-D to exit): cat
"cat" was found as below.
1 times in the northward direction
0 times in the southward direction
0 times in the eastward direction
1 times in the westward direction
0 times in the northeastward direction
0 times in the southeastward direction
1 times in the southwestward direction
1 times in the northwestward direction
-t-t-
--aa-
---c-
--a--
-tacEnter
a word to search in the puzzle (or CRTL-D to exit):
p t a t i
d o a a c
o r i c e
g o a n a
e t a c t
You can assume the file specified by the user can always be opened for reading and follows the following format.
The puzzle saved in a file will be of a square shape.
Each line of the file corresponds to a row of the puzzle.
There are no blank lines between two rows.
Each line starts with a letter and ends with a newline.
There are no space or tabs between two letters.
The puzzle size can be determined by counting the number of letters before the first newline.
You can further assume a word entered by the user will have a length from 2 through 100. Please see an actual word
search puzzle and its related words at the end of this document.
What You Need To Do

CS 100作业代做
Create a directory named project5 on your machine. In that directory, create a file named puzzle.c
In puzzle.c, write the code needed to solve the problem stated above. Make sure that your program has
a header block of comments that includes your name and a brief overview of the program.
When you are ready to submit your project, compress your project5 directory into a single (compressed)
zip file, project5.zip. See the Basics document on Blackboard if you don’t remember how to do it.
Once you have a compressed zip file named project5.zip, submit that file to Blackboard.
Project 5 is due at 5:00pm on Wednesday, April 3. Late projects are not accepted.
This document including its associated files is for your own personal use only.
You may not post this document or a portion of this document to a site
such as chegg.com without prior written authorization.
A project shall be completed individually, with no sharing of code or solutions.
All submissions will go through MOSS (Measure Of Software Similarity)
for similarity check.
The University of Alabama’s Code of Academic Conduct will be rigorously enforced.
Sample execution of the program
./a animal.dat
The word puzzle is:
GEZDQQTIKIOPOSSUMCGRR
EDBVFENXRANLHNDGOATEX
RGHJLEUINGIIAYLXPDTAL
BHWDPYRIWAFEMWXNHSLGG
IJNDEDHRUWVCSRLVBLJOI
LKMKICMQEPWTTUAOIFDLW
HPNARCATKTFYEVLHFNBDT
FODURTQGIHUURDCRDDNFS
MKAZMIFKUWOTDNNDOEYIA
QEWYEDNDSISRIIJQKCVSL
SOQSDWIEMUNHSPSCWJSHA
CEOWEGQYSFCEFEITMPNQM
WOODCHUCKPRWAHRATIAAA
GRYXLHUTJBOUCPHBFGKWN
HTAGSHEEPBANIRISAEEAD
MFFBAJLPSBMBGTPGNOEZE
ORRZBVIAKGVIOEFGBNDKR
UOBWOIMWOPHLKOPLVVBZS
SGMCWHTDTURTLENIYQVMD
ENMZRRNLIZARDOWEGZQWT
ARMADILLOJMGXGABDCJFM
Enter a word to search in the puzzle (or CRTL-D to exit): RABBIT
"RABBIT" was found as below.
0 times in the northward direction
0 times in the southward direction
0 times in the eastward direction
0 times in the westward direction
0 times in the northeastward direction
1 times in the southeastward direction
0 times in the southwestward direction
0 times in the northwestward direction
Enter a word to search in the puzzle (or CRTL-D to exit):
Please search the words below.
ARMADILLO BABOON CAT CHICKEN CHINCHILLA
COW DOG FERRET FROG GERBIL GOAT GOLDFISH
GOOSE HAMSTER HORSE LIZARD LOBSTER MONKEY
MOUSE OPOSSUM PIG PIGEON QUAIL RABBIT RAT
SALAMANDER SHEEP SNAKE TURTLE WOODCHUCK

因为专业,所以值得信赖。如有需要,请加QQ99515681 或邮箱:[email protected] 

微信:codinghelp

猜你喜欢

转载自www.cnblogs.com/ffadf/p/10609930.html
今日推荐