Beginner C++ help

Discussion in 'Tech Talk & Computing' started by maos, Oct 8, 2012.

  1. Hey guys, for my beginners programming class in C++ I have to make a menu that does a variety of basic tasks,simple enough.

    However there are two blocks of code that I can't figure out, maybe I could get some help?

    I have to create four exact pyramids of asterisks just in different orientations.
    I have the first two done:

    Code:
     // Option 9 code
    
        if( choice == 9 )
    
        {
    
            int mark9;
    
            int mark9A;
    
    
            for( mark9 = 0; mark9 < 10; mark9++ )
    
            {
    
                for( mark9A = 1; mark9A <= mark9 + 1; mark9A++ )
    
                {
    
                    cout << "*";
    
                }
    
    
                cout << endl;
    
            }
    
        }
    
    
        // Option 10 code
    
        if( choice == 10 )
    
        {
    
            int mark10;
    
            int mark10A;
    
    
            for( mark10 = 10; mark10 > 0; mark10-- )
    
            {
    
    
    
    
                for( mark10A = 1; mark10A < mark10 + 1; mark10A++ )
    
                {
    
                    cout << "*";
    
                }
    
    
    
    
    
            }
    
        }


    Option 9 makes this pyramid:
    *
    **
    ***
    ****
    *****
    ******
    *******
    ********
    *********
    **********

    and option 10 makes this pyramid:
    **********
    *********
    ********
    *******
    ******
    *****
    ****
    ***
    **
    *

    The part that I'm having trouble with are the last two pyramids I have to create, them being in these shapes:
    Code:
    [RIGHT]**********
    
      *********
    
        ********
    
          *******
    
            ******
    
              *****
    
                ****
    
                  ***
    
                    **
    
                      *[/RIGHT]

    and
    Code:
    [RIGHT] *
    
                    **
    
                  ***
    
                ****
    
              *****
    
            ******
    
          *******
    
        ********
    
      *********
    
    **********[/RIGHT]


    Now I'm pretty sure the initialization, condition, and increment for the FOR loops should be the same for the next two pyramids,its just the outputs that change the look?

    If you can help,that would be greatly appreciated
     

Share This Page