|
1. WORD TRIANGLES WORD TRIANGLES look like E N N C C O O D D E N C O D E Any word that begins and ends with the same letter can be made into a WORD TRIANGLE. Your job is to write a program that will print out WORD TRIANGLES for any word that begins and ends with the same letter. Your program should ask the user to enter a word, check that it satisfies the given properties, and print out the WORD TRIANGLE if it can be done. Test your program with the words: CUBIC, ROOT, ELLIPSE. Sample Run ENTER A WORD: NOON N O O O O N O O N 2. SPORT OF KINGS Man o' War and Swaps, two great horses from racing history, are back again to race each other. But this time it is to be done on the computer. Write a program that will simulate the greatest horse race of all time. Here are the rules. 1.The track is 1000 yards in length. The winner is the first horse to travel 1000 yards or more. 2.Man o' War advances X yards while Swaps advances Y yards according to the rules: X = 9 * Y + 11 - 64 * (INT (( 9 * Y + 11)/64)) Y = 9 * X + 12 - 64 * (INT (( 9 * X + 12)/ 64)) 3.To begin the race, a seed number is chosen for Y. This seed number is used to compute Man o' War's first advancement X. The resulting X value is used to compute Swap's first advancement Y. The resulting Y value is used to compute Man o' War's second advancement X. The resulting X value is used to compute Swap's second advancement Y. The moves continue in this way until the race is over. 4.Three races are run. The seed numbers used are 1, 2 and 3 respectively. Compute the winner of each race and the greatest horse of all time -- the winner of two or more races. Sample Run SPORT OF KINGS Race Winner 1 MAN O' WAR 2 SWAPS 3 MAN O' WAR THE GREATEST HORSE OF ALL TIME IS MAN O' WAR. 3. CRUNCH MSSSSPP is the crunched version of the word MISSISSIPPI with all the I's taken out. A phrase can be crunched too! RLRD CRSSNG is the crunched version of RAILROAD CROSSING The letters A, I, and O have been crunched out. Write a program that will CRUNCH out any string of letters supplied by the user from any phrase (up to 60 characters long). 1. The program should ask the user to enter a phrase and any string of letters to be crunched out. Test your program with the phrases: RAILROAD CROSSING WITHOUT ANY VOWELS (Remove the vowels EAIOUY) CRUNCH A BUNCH OF MUNCHIES FOR LUNCH (Remove the vowels AEIOUY) Sample Run ENTER A PHRASE: RAILROAD CROSSING WITHOUT ANY VOWELS ENTER STRING OF LETTERS TO BE CRUNCHED OUT: AEIOUY RLRD CRSSNG WTHT N VWLS 4. WORLD SERIES In the World Series of Baseball two teams play each other until one team wins four games. The first team to win four games is the winner, and the series ends. There must be at least four games played in a world series and it can last for up to seven. Write a program that will show all the ways a World Series can be won or lost by a baseball team. A game loss is indicated with an L, a win is noted with a W. The outcome of the series is a WIN or a LOSS. Write a program that will generate a listing similar to the one shown in the sample run. Your program does not have to list the outcomes in the same order, but it must list them all. Also, count the total number of possible World Series. Sample Run POSSIBLE WORLD SERIES GAME 1 2 3 4 5 6 7 SERIES L L L L LOST L L L W L LOST L L L W W L......LOST L L L W W W L ...LOST L L L W W W W WIN L L W L L LOST L L W L W L LOST L L W L W W L LOST L L W L W W W WIN ...................... ...................... ...................... ...................... W W W W WIM TOTAL NUMBER OF UNIQUE WORLD SERIES = ? 5. WELL ORDERED NUMBERS The number 138 is called WELL-ORDERED because the digits in the number (1,3,8) increase from left to right (1 < 3 < 8). The number 365 is not well-ordered because 6 is larger than 5. Write a program that will find and display all possible N digit WELL-ORDERED numbers where N is chosen by the user (1 _ N _ 9). Report the total number of N digit WELL-ORDERED numbers. Test your program for N = 3, and N = 8. Sample Run WELL-ORDERED NUMBERS ENTER THE NUMBER OF DIGITS: 8 THE 8 DIGIT WELL-ORDERED NUMBERS ARE: 12345678 12345679 12345689 12345789 12346789 12356789 12456789 13456789 23456789 THE TOTAL NUMBER IS:9
|