1 SQUARE DESIGN Write a program that will generate a Square Design like the one below one for any value of N (N is the number of rows and columns of Xs). Test your program for N = 5 and N = 7. Sample Run +-----------+ I-X-X-X-X-X-I I-X-X-X-X-X-I I-X-X-X-X-X-I I-X-X-X-X-X-I I-X-X-X-X-X-I +-----------+ 2 ORDERED SQUARES A 6-digit number STWXYZ is called an Ordered Number if the difference between the first three digits, STW, and the last three digits, XYZ, is equal to 1 (STW-XYZ=1 or XYZ-STW =1). For example, 123124 and 876875 are Ordered Numbers. A number is a Square if it is equal to the product of one whole number multiplied by itself. For example, 144 is a Square since 144 = 12x12. An Ordered Square is both an Ordered Number and a Square. Write a program that finds all 6-digit Ordered Squares. Sample Run THE 6-DIGIT ORDERED SQUARES ARE: 183184 328329 528529 715716 3 WINNING COMBINATIONS Three runners, A, B, and C, enter as a team in a 10 mile relay race. Each runner can run from 1 to 8 miles (no fractions). All runners have a normal time in seconds that they run for each mile. It is derived by the following rule: Time in seconds for Nth mile Runner A 256 + 9xN +11 -16xINT((9xN+11)/16) Runner B 256+13xN +15 -16xINT((13xN+15)/16) Runner C 256 + 7xN +10 -16xINT((7xN+10)/16) Write a program that will determine how many miles each runner should run in order for the team to have the best time. This is called the Winning Combination. Sample Run RUNNER MILES A 3 B 5 C 2 BEST TIME: 2622 SECONDS 4 JUSTIFYING TEXT Write a program that will accept a sentence of text in any convenient way and print out the sentence in a column 20 characters wide. Words at the end of a line that would lengthen the line beyond 20 characters must be moved to the next line. Spaces must be added between words so that each line except the last is exactly 20 characters wide. This is called Justifying Text. Test your program by entering the sentence: A great discovery solves a great problem but there is a grain of discovery in the solution of any problem. Sample Run A great discovery solves a. great problem but there is a grain of discovery in the solution of any problem. 5 PRIME CRYPTARITHM The following multiplications problem can be solved by substituting only prime digits (2, 3, 5, or 7) into the positions marked *. This is called a Prime Cryptarithm. * * * x * * ------- * * * * * * * * --------- * * * * * Write a program that will find all solutions to this Prime Cryptarithm. Sample Run 7 7 5 x 3 3 ------- 2 3 2 5 2 3 2 5 --------- 2 5 5 7 5
|