Help with C++ pattern including spaces

This is a discussion on Help with C++ pattern including spaces within the C++ Programming forums, part of the General Programming Boards category; Hello. I need help altering the attached code to reflect the following pattern: Code: ********* ******** ******* ****** ***** **** ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    3

    Unhappy Help with C++ pattern including spaces

    Hello. I need help altering the attached code to reflect the following pattern:

    Code:
    *********
      ********
        *******
          ******
            *****
              ****
                ***
                  **
                    *
    and
    http://cboard.cprogramming.com/attac...1&d=1161659356
    Ch8ConE08.cpp
    Code:
                    *
                  **
                ***
              ****
            *****
          ******
        *******
      ********
    *********
    I am taking an intro class and tearing my hair out. Thanks!
    Attached Files Attached Files
    Last edited by Dave_Sinkula; 10-23-2006 at 09:17 PM. Reason: Added [code][/code] tags to preserve whitespace.

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3
    For some reason, my pattern was changed when posted. I really need to know how to write the pattern so that the first line has 9 asterisks, second line has 8, third line has 7, and so on - down to 1. All asterisks should be flush right margin row 1 begins 9 asterisks in col 1, row 2 begins 8 asterisks in col 2, etc.

    This is hard to explain, so I hope I'm making sense!!

    Thanks!

  3. #3
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Use [code][/code] tags to preserve whitespace, I dont think my simple edit is what you had in mind.

    Don't try messing with the interpreter, just use the tags.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    3
    Thanks so much, Dave. I will look into these tags. I appreciate your prompt response!!

  5. #5
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    If you want leading whitespace, you'll need a loop that puts out leading whitespace.

    [edit]Such as,
    Code:
                for (col = 1; col <= row; col ++)
                {
                   cout << " ";
                }//end for
    or
    Code:
                for (col = 1; col <= (10 - row); col ++)
                {
                   cout << " ";
                }//end for
    cleverly placed.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Changing 3 spaces to tabs
    By dnguyen1022 in forum C Programming
    Replies: 2
    Last Post: 12-21-2008, 11:51 PM
  2. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 04:02 AM
  3. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  4. fgets - user input including spaces
    By MethodMan in forum C Programming
    Replies: 24
    Last Post: 03-12-2004, 06:36 PM
  5. Including spaces with an ifstream...
    By Trauts in forum C++ Programming
    Replies: 14
    Last Post: 10-30-2002, 06:56 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21