Sunday, March 14, 2010

The Fourth Annual Computer Competition (Part 2 of 4)

(Introduction and Part 1Part 2, Part 3, Part 4)

Question #3: Senior Division

Write a program that accepts a sentence for input and outputs the sentence with the letters in each word arranged in alphabetical order, and the words in order of length. Words must still be separated by spaces. If two rearranged words are of equal length they are to be placed in alphabetical order of the output "sentence".

NOTE: The judge will input only upper-case letters and will terminate the sentence with a period. This will be the only punctuation in the sentence and must remain at the end of the output sentence.

SAMPLE RUNS

RUN
WHAT IS YOUR SENTENCE? THIS IS A SENTENCE FOR YOU TO EXAMINE.
A IS OT FOR OUY HIST AEEIMNX CEEENNST.

RUN

WHAT IS YOUR SENTENCE? WE ARE NOT ALL HERE NOW.
EW AER ALL NOT NOW EEHR.


No comments: