receiving an image/ structure with c++

Hi, I am struggeling with this:
i have this "image/structure" given:

0
00
000
0000
00000
000000
0000000
000000
00000
0000
000
00
0

and i need to find two ways of receiving it. One by using one or two loops and the other needs to be with recursion.
i am a beginner with c++ and I can't think of anything useful.
-I would be really happy if someone could help me out a bit!
What do you mean by "receive"? A common beginner homework is to print shapes. Is that what you are trying to do?

This is a "loop" homework problem.

Notice that the middle row has seven zeros, and that it is also the seventh row.

Also notice that all the other rows before the middle row have the same number of zeros as the row number itself. (Row 1 has 1 zero; row 2 has 2 zeros, row 3 has 3 zeros, ...)

Think about this and how to do it with loops. You'll need two loops - one for the row, and one for the zeros.

Give it a try and post back.
I somehow managed to get the " image". unfortunatly only with the help of some class material. I copied the " for(;j;j--)" and dont understand what in particular it is doing. I would be very thankful i you could explain this to me :)

#include<iostream>
using namespace std;

void main()
{
int i,j,n;
cout<<"insert a number ";
cin>>n;
n=n+1;

for(i=1;i<=n;i++)
{
j=i-1;
for(;j;j--)
cout<<"0";
j=i;
cout<<endl;
}
for(i=2;i<=n;i++)
{
j=n-i;
for(;j;j--)
cout<<"0";
j=n-i+1;
cout<<endl;
}

system("Pause");

}
Patience, young paduwan.

http://www.cplusplus.com/doc/tutorial/control/#for

The for(i=... loop counts up from 0 to n-1 (stopping when i==n).

The for(;j... loop counts down from i to 1 (stopping when j==0).

Hope this helps.


Oh, please put your code in [code] tags, and delete your other topic about this question before someone replies to it.
Topic archived. No new replies allowed.