Purpose : write a program to cross words in scrabble.
Consider two words. We say that the first word crosses with the second at (i,j) when the i-th letter in the first word matches the j-th letter in the second word. For instance, "hello" crosses with "world" at (3,4) at 'l'. This crossing can be visualized like
w o r hello dWrite a program that takes two strings as arguments on the command line and that displays all crossings of the first string with the second. When the second string crosses with the first at (i,j) for the same i, but at multiple j's, only the crossing with lowest index j needs to be displayed. See the examples below
Your prompt> scrabble welcome hello
Crossing "welcome" with "hello" :
h
e
h l
he l h
welcome
ll l
lo l
o o
Your prompt>
Observe that the second crossing of "hello" crosses with
"welcome" occurs at the first and not the second 'l'.
Your prompt> scrabble hello welcome
Crossing "hello" and "welcome" :
w
e
wwl
weec
hello
lccm
cooe
omm
mee
e
Your prompt>
In case the words do not cross, or when the user gives too few words, your program should react as follows:
Your prompt> scrabble hello party "hello" does not cross with "party". Your prompt> scrabble hello We need two words to scrabble. Please call again. Your prompt>You may ignore the extra strings when the program is called with more than two arguments.
Do not make any assumptions on the maximal length of the strings. Test your program on one letter words (like "a").
Note that the command line arguments are not limited to Unix. Under Windows you can get a prompt in a DOS like window and execute your program in that window.
The listings of your program will be collected at the start of the lecture on Monday 19 February, at 1PM. Also send the code by e-mail to jan@math.uic.edu. The first line of your program should be like
/* MCS 275 Project Two by < Author > */
where you replace the < Author > by your name.
/* MCS 275 Project One by Write appropriate documentation inside the code to comment on your subroutines. The gcc compiler will be used to test your program. So even if you have developed your program in a Windows environment, it may be good to run your final version on icarus.cc.uic.edu where the gcc compiler is installed. A final note to Windows users: with the Cygwin tools you can use the gnu tools from Windows.
If you have questions, comments, or difficulties, feel free to come to my office for help.