0
   Can you give an idea how  to create this pattern:7.  Write a program to display the following pattern

                                                 x x x x x
                                                 x x x x x 
                                                 x x x x x 
                                       x x x x x x x x x x x x x x x
                                       x x x x x x x x x x x x x x x
                                       x x x x x x x x x x x x x x x
                                                 x x x x x
                                                 x x x x x 
                                                 x x x x x 
    I know it should be simple enough 
    I just starting c++ and would like to see the process.My guess is: need to use 
    for loop and if statement,but how to combine it together?Regards
3
Contributors
2
Replies
13
Views
3 Years
Discussion Span
Last Post by Learner010
0

Start by printing a block of x's:

for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 15; j++) {
        cout.put('x');
    }

    cout.put('\n');
}

From there you can play around with ideas on how to identify the corner blocks and instead of printing an x, print a space. The real benefit of this exercise is that part, so I don't want to reveal too much as that would defeat the purpose.

0

instead of printing an x, print a space.

yes. you have to print some spaces using another loop. but try it yourself.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.