write a program to find words that are hidden in a square of
letters. Below is an example:
x z v g k u p
g s n i b p k
p i a n o d g
l w c e l l o
b q z h s u a
t b n s g w b
l k r t q f h
Starting from any character in the square, move to the left, to the right, up,
down, or on any of the four diagonals Your task is to find words
that can be spelled out with those characters on the moving path. For example,
you might have found the above square contains the word “viola” starting from
the ‘v’ in the first row to the last character in the fifth row. Similarly, you’ll
find “piano” and “cello”. For “piano”, you may wonder if words “a”, “a”, and
“no”, which are sub-strings of “piano”, count. The answer is yes and no. If a
word is part of another word, both words should be found, for example, “prose”
and “prosecution”. However, we just ignore a word if its length is less than or
equal to 4. In fact, you don’t need to consider the latter restriction, because we
shall provide you a dictionary containing no short words .
[img]/upload/attachment/99946/1104327c-66d0-3745-bc7a-5c104b0c508d.jpg[/img]
Thanks !!
(注:您只需提供具体算法或者分析的思路!谢谢~)