because you're putting it there...
your outer loop steps through the one-d array. so, you start at the first element. then, your inner 2 loops step through the 2d array. but each time you get to the assignment, you're sitting on the first element, constantly re-assigning values to it. when you finish the 2d array, your 1st element of the 1-d get assigned the last value of the 2d.
then, you go to the 2nd element of the 1d. keep re-assigning, until the last value in the 2d gets put there...
and so on.
get rid of the outer loop. declare an int outside of the two remaining loops, initialized to 0. then, depending on if you want 0's in your array or not, increment the counter either inside or outside the if block.
i don't want to give too much away, but i hope this helps.
f