#2D array help

15 messages · Page 1 of 1 (latest)

copper leaf
#

cant seem to get my array to go like this with my nested for loop, tried everything i can think of
this is as far as ive gotten

                for (int i=0; i<=9; i++) {
                    for (int j=9-i ; j>=7-i; j--) {
                        if (j>=0)
                            m[i][j] = n++;
                    }
                }```
late pewterBOT
#

This post has been reserved for your question.

Hey @copper leaf! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

copper leaf
#

There is a difference of two on each number (3, 5, 7) in each row and a difference of three on each column (3, 6, 9)

#

except the first row with "1"

#

you can probably make use of that

wheat elbow
copper leaf
#

technically doesnt matter, ive tried both ways with 1++ and 27--

wheat elbow
#

i just wanna know

#

.-.

#

but ok

wheat elbow
#
int counter=1;
        int threeRow=usableLength+2;
        for(int j=usableLength;j>=0;j--){
            for(int i=threeRow;i>threeRow-3;i--){
                if(i<=usableLength && i>=0){
                    finalArray[i][j]=counter;
                    counter++;
                }
            }
            threeRow--;
        }

#

dont judge my crapy style :/