Need help with 10x10 array assignment

Hello everyone i need help in making 10x10 array in which it all containts 0 then i would have to put 1 in random elements in it then when finished, the program should count how many objects are found. which means that how many 1's are in a form of six. examples are
111111
or
1111
11
or
11
11
11

and such.. Thankyou for your help! it will be really appreciated. Sorry i'm very noob at programming.
Please show us what you've done so far. Also, if possible, post the actual assignment.

i would have to put 1 in random elements in it
Can you give more detail here? How many 1's do you put in? If you randomly pick the same square twice, do you have to pick another square instead?

In terms of "groups of six", what about
11111
1
and
111
111

Do you have to get these too? And consider this pattern:
11111
11
It matches
11111
1
and
1111
11
so does it count as 2 matches or 1?

This may seem like nit picking, but in reality these sorts of very specific questions are essential to programming.
the inputting goes through horizontally. Actually, we can put any number but only those with 1 will be recognized as long as it is in a groups of six for example:

0001111110
1110000000
1110000000
0001111100
0001000000
1111000000
1100000000

would give me 3 objects. Sorry but i havent done anything so far because we don't exactly have an idea on how to make an arrays because we were just on looping then he brought this up.
Last edited on
You might want to read the tutorial on arrays: http://www.cplusplus.com/doc/tutorial/arrays/

The most important thing to remember with arrays is that the index starts at 0, not 1. So if you declare an array of 10 elements, you access them with indexes 0-9, not 1-10.

To define a 10x10 array of integers:
int myarray[10][10];

One way to access it is like this:
1
2
3
4
5
6
for (int i=0; i<10; ++i) {
    for (int j=0; j<10; ++j) {
        cout << myarray[i][j];
    }
    cout << '\n';
}

Topic archived. No new replies allowed.