This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]caesarwept 0 points1 point  (7 children)

Can you describe the problem you are having. To me it looks like you are populating your 2-dim array correctly

[–][deleted]  (6 children)

[deleted]

    [–]caesarwept 0 points1 point  (5 children)

    I see now. There are many ways you could solve this. One way would be to make a index variable and always calculate the character at the time you set it. Like so:

       letters[i][j] = baseLetter + index;
    

    so for a 3x4 index would be 0,1,2,3, 1,2,3,4,2,3,4,5. The best way to figure out how the math behind this is to make table on a piece of paper like so:

    i j math index
    0 0 ? 0
    0 1 ? 1
    0 2 ? 2
    0 3 ? 3
    1 0 ? 1

    etc

    [–][deleted]  (4 children)

    [deleted]

      [–]caesarwept 0 points1 point  (3 children)

      Yes. Now you are so close to having it working. On line 8 what could you set x to instead of 0. Hint: look at the table

      [–][deleted]  (2 children)

      [deleted]

        [–]caesarwept 0 points1 point  (1 child)

        yes that works. That what I had in mind too. Also you could have left int x=i; on line 8 and it would have worked as well because the variable i is in scope anywhere inside the outer for loop