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;
}

Edited 3 Years Ago by Reverend Jim: Fixed formatting

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

Edited 6 Years Ago by gerard4143: n/a

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;
}

Edited 3 Years Ago by Reverend Jim: Fixed formatting

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;
}

This question has already been answered. Start a new discussion instead.