C Primer Plus 第六章第四題

4. Have a program request the user enter an uppercase letter. Use nested loops to produce a pyramid pattern like this:

          A
         ABA
        ABCBA
       ABCDCBA
      ABCDEDCBA

The pattern should extend to the character entered. For example, the preceding pattern would result from a input value of E. Hint: Use an outer loop to handle the rows. Use three inner loops in a row, one to handle the spaces, one for printing letters in ascending order, and one for printing letters in descending order.

Posted in 碎碎念

Leave a Reply

Your email address will not be published.