Homework 5

Due in Upson 5162 on Thursday, February 24.

Turn in a HARDCOPY of your source code with your NAME and STUDENT ID. IN ADDITION, EMAIL ME YOUR SOURCE CODE SO THAT I HAVE A TIME-STAMP.

If you find either of the problems ambiguous, make what you think are reasonable assumptions, state what they are, and solve the problem with respect to your assumptions.

Problem: Word re-arrangements

Write a program which accepts a word (guaranteed to be of length < 80) and outputs all permutations of the letters. The letters of the word are not necessarily distinct; no permutation should be repeated. Check your program with the examples given VERY CAREFULLY.

Here's a sample interaction with my program:

Enter a word: bob
bob
bbo
obb    

And, here's yet another sample interaction with my program:

Enter a word: anna
anna
anan
aann
nana
naan
nnaa

Problem: Reverse a sentence

Write a program which accepts a phrase, eliminates all punctuation, and outputs the phrase, but with the WORDS in reverse order. The phrase is guaranteed to be of length < 80.

Here's a sample interaction with my program:

Enter a phrase: Joe went to the store.
store the to went Joe
Here's another.
Enter a phrase: Check your program - carefully!!!
carefully program your Check