Hello all,

I am having issues with a homework assignment. My assignment is as follows:
Write a program that uses a loop to display Pattern A below, followed by another loop that displays Pattern B.

Pattern A:

+
++
+++
++++
+++++
++++++
+++++++
++++++++
+++++++++
++++++++++

Pattern B:

++++++++++
+++++++++
++++++++
+++++++
++++++
+++++
++++
+++
++
+

So the above is how the program is supposed to be displayed, but the program I wrote, just basically has Pattern B configured exactly like Pattern A. I am completely stumped and do not know where to go from here, so if I could please get a hint in the right direction, I would greatly appreciate it. Thanks!

//Pattern Displays.
#include<iostream>
using namespace std;

int main()
{
    const int columns=9;
    const int rows=10;

    const int height=10;

    cout<<endl<<"============"<<endl;
    cout<<endl<<" Pattern A:"<<endl;
    cout<<endl<<"============"<<endl;
    for(int rows=0; rows<height; rows++)
    {
        for(int a=0; a<1*rows+1;a++)
            cout<<"+";
        cout<<endl;
    }
    cout<<endl<<"=============="<<endl;
    cout<<endl<<" Pattern B:"<<endl;
    cout<<endl<<"=============="<<endl;
    for(int rows=0; height>rows; rows++)
    {
        for(int b=0; b<1*rows+1;b++)
            cout<<"+";
        cout<<endl;
    }
    system("pause");
    return 0;
}

Instead of starting at zero and incrementing try starting at columns value and decrementing to zero..

Hi Gerard 4143,
Thanks for responding, I'm still lost. It's my assumption that my line 26 that starts with for(int b=1..etc) is going to be the lets say "action line" for lack of a better word right now.
I did a revision to my program from what I though you were hinting at, but now every odd number line (under pattern B only)has an infinite number of characters, and every even number line (under pattern B only) has exactly 8 characters. I'm very confused about the logic of this so maybe explaining that would help me a little more.

//Pattern Displays.
#include<iostream>
using namespace std;

int main()
{
    const int columns=9;
    const int rows=10;

    const int height=10;

    cout<<endl<<"============"<<endl;
    cout<<endl<<" Pattern A:"<<endl;
    cout<<endl<<"============"<<endl;
    for(int rows=0; rows<height; rows++)
    {
        for(int a=0; a<1*rows+1;a++)
            cout<<"+";
        cout<<endl;
    }
    cout<<endl<<"=============="<<endl;
    cout<<endl<<" Pattern B:"<<endl;
    cout<<endl<<"=============="<<endl;
    for(int rows=0; rows<height; rows++)
    {
        for(int b=1; b<10*columns-1;b++)
            cout<<"+";
        cout<<endl;
    }
    system("pause");
    return 0;
}

Hi Gerard 4143,
Thanks for responding, I'm still lost. It's my assumption that my line 26 that starts with for(int b=1..etc) is going to be the lets say "action line" for lack of a better word right now.
I did a revision to my program from what I though you were hinting at, but now every odd number line (under pattern B only)has an infinite number of characters, and every even number line (under pattern B only) has exactly 8 characters. I'm very confused about the logic of this so maybe explaining that would help me a little more.

//Pattern Displays.
#include<iostream>
using namespace std;

int main()
{
const int columns=9;
const int rows=10;

const int height=10;

cout<<endl<<"============"<<endl;
cout<<endl<<" Pattern A:"<<endl;
cout<<endl<<"============"<<endl;
for(int rows=0; rows<height; rows++)
{
for(int a=0; a<1*rows+1;a++)
cout<<"+";
cout<<endl;
}
cout<<endl<<"=============="<<endl;
cout<<endl<<" Pattern B:"<<endl;
cout<<endl<<"=============="<<endl;
for(int rows=0; rows<height; rows++)
{
for(int b=1; b<10*columns-1;b++)
cout<<"+";
cout<<endl;
}
system("pause");
return 0;
}

for(int b=10,b>0,b--) {
.....
}

for(int b=10,b>0,b--) {
.....
}

Thank you both so much for your responses, I really appreciate the help. I had to slightly rework my program, but the result was successful! So thanks again!!!!

//Pattern Displays.
#include<iostream>
using namespace std;

int main()
{
    int col=10;
    int row=10;

    cout<<endl<<"Pattern A:"<<endl;
    for(int row=0; row<10; row++)
    {
        for(int col=0; col<row;col++)
            cout<<"+";
        cout<<endl;
    }
    cout<<endl<<"Pattern B:"<<endl;
    for(int row=10; row>=1; row--)
    {
        for(int col=1; col<row;col++)
            cout<<"+";
        cout<<endl;
    }
    system("pause");
    return 0;
}
      *
   *    *
*     *     *   
*     *     *
   *     *
      *

Please help me! Thanks

This thread has already been answered. Please start a new thread with your question. I strongly suggest you show us what you have done to try to solve the problem yourself. You can't expect us to show any effort if you haven't. You may want to read the Daniweb Posting Rules as well as Read This Before Posting a Question to increase your chances of getting a timely (and more useful) response.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.