CS 1440 Programming Contest

All work must be completed individually.  You are allowed to use your book and web material, but no help from others.
Each individual who successfully solves at least one problem will receive a 100 on a lab grade. In addition, the top three individual will receive the following extra credit: You do not have to solve the problems in the given order. Call your program something that corresponds to the problem number (Example: you can call program 1, pc1.C). Be sure to follow the directions in each problem as far as the behavior of your program. If you do not follow the directions exactly, the program will not count as a solution and you will not receive partial credit for it.

Create a lab12 subdirectory in the 1440 directory of one of the group members. Put all work for lab12 in that subdirectory. As soon as you think you have solved a problem correctly, tell me the name of the file containing the program and I will move it to my directory to check it.

1) Write a program that will take as input a decimal digit, i.e., 0-9, and draw a triangle of the given decimal digit height with each column containing the digit corresponding to the number of digits in the column. For example, if the user enters 5, the following picture would be drawn:

    5
    54
    543
    5432
    54321
2)Problem 5, p. 437 of your text. Write a program that accepts a year written as a four-digit Arabic (ordinary) numeral and outputs the year in Roman Numerals. Important Roman numerals are: V for 5, X for 10, L for 50, C for 100, D for 500 and M for 1000. Recall that some numbers are formed by using a kind of subtraction of one Roman "digit"; e.g., IV is 4 produced as V minus I, XL is 40, CM is 900, etx. A few sample years: MCM is 1900, MCML is 1950, MCMLX is 1960, MCMXL is 1940, MCMLXXXIX is 1989. Assume the year is between 1000 and 3000.
     
     
     
3)  Problem 8, pp. 170-171 of your text.
Write a program that asks for the user's height, weight, and age, and then computes clothing sizes according to formulas:
4) Write a program that takes as input a four digit integer and prints out the digits vertically to the screen. Following is an example:
        Enter a four digit number:  5678
    
        5
        6
        7
        8
5) Write a program that asks the user for the number of characters, n, in a string and then asks the user to input that many characters. Finally, the program generates all permutations for the string of length n and outputs each permutation to the screen.
    Following is an example:
       Please enter the number of characters: 3
       Please enter a string of length 3:     cat
       Here are the permutations of cat:
            cat
            cta
            tca
            tac
            act
            atc
    (Hint: The number of permutations of a string is equal to the factorial of the length of the string.)
6) A Pythagorean Triple is a sequence of 3 integers a, b, and c, satisfying the following properties:

                1) 0 < a < b < c; and
                2) c2 = a2 + b2.
Write a program that takes 3 integers as input and reports whether they form a Pythagorean Triple.

    Example 1:
    
    Enter a: 3
    Enter b: 4
    Enter c: 5
    A Pythagorean Triple.
    
    
    Example 2:
    
    Enter a: -3
    Enter b: 4
    Enter c: 5
    Not a Pythagorean Triple.