OK, now I'm making the arrays two different sizes and haven't figured out exactly how to populate the vector correctly.
Although I'm coding with "for loops" in this one, I also tried the"assign" method which was basically the same output.
Here's the code and output:
Code:
int main()
{
int typeArray[4] = {55,66,77,88};
int valArray[13] = {1,2,3,4,5,6,7,8,9,10,10,10,11};
// 4 = LENGTH or NUMBER of ROWS; 13 = WIDTH or NUMBER of COLUMNS;
// 0 = VALUE all cells are initialized to
vector< vector <int> > myVector(4, vector<int> (13,0));
for (int i = 0; i < 4; i++)
{
myVector[i][0] = typeArray[i];
for (int j = 0; j < 13; j++)
{
myVector[1][j] = valArray[j];
}
}
// print to screen
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 13; j++)
{
cout << myVector[i][j] << ' ';
}
cout << '\n';
}
Before I post the output, I realize that if I want "valArray" to populate to the right of COLUMN 0,0 I should put [j][1], however, I keep getting an error when I do that.
Here's the OUTPUT:
55 0 0 0 0 0 0 0 0 0 0 0 0
1 2 3 4 5 6 7 8 9 10 10 10 11
77 0 0 0 0 0 0 0 0 0 0 0 0
88 0 0 0 0 0 0 0 0 0 0 0 0
Press any key to continue . . .
-------------------------------------------
Please advise, I'm not quite getting it yet, thanks!