Issue
I need to fill an 8x8 matrix just with 0.
I know it is possible to do the following:
board = arrayOf(
intArrayOf(0, 0, 0, 0, 0, 0, 0, 0),
intArrayOf(0, 0, 0, 0, 0, 0, 0, 0),
intArrayOf(0, 0, 0, 0, 0, 0, 0, 0),
intArrayOf(0, 0, 0, 0, 0, 0, 0, 0),
intArrayOf(0, 0, 0, 0, 0, 0, 0, 0),
intArrayOf(0, 0, 0, 0, 0, 0, 0, 0),
intArrayOf(0, 0, 0, 0, 0, 0, 0, 0),
intArrayOf(0, 0, 0, 0, 0, 0, 0, 0),
)
This time is just an 8x8 so it's not too much work, but what if I have an 200x200 matrix, what should I do?
Solution
val board = Array(8) { IntArray(8) { 0 } }
Answered By - lukas.j
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.