I just started using c++, so I am still new to vectors and data structures. I'm wondering how to I add a int value into a specific index location of 2d vector. For example, I have a multidimensional vector "chessboard" initialized like:
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
How do I use the insert()
method to insert a integer value 1 into say the x,y index [4,3] so It looks like this:
0 0 0 0 0
0 0 0 0 0
0 0 0 1 0
0 0 0 0 0
This Is my code so far:
vector<vector<int>> board(boardsize, vector<int> (boardsize, 0));
int x = 4; // x position for value to be inserted
int y = 3; // y position for value to be inserted