Я понимаю, что если я хочу, чтобы "valArray" заполнял справа от "COLUMN 0,0", я должен поставить "[j] [1]", однако, я продолжаю получать ошибку, когда делаю это.
ВЫХОД:------------------------------------------------ -------------------------------------------------- --------------------------------------------------
55 0 0 0 0 0 0 0 0 0 0 0 0 ------- ЭТО СТРОКА 1 -------------------------- -------------------------------------------------- --------------------
1 2 3 4 5 6 7 8 9 10 10 10 11 ---- ЭТО РЯД 2 ----------------------------- -------------------------------------------------- ----------------
77 0 0 0 0 0 0 0 0 0 0 0 0 ------- ЭТО СТРОКА 3 -------------------------- -------------------------------------------------- --------------------
88 0 0 0 0 0 0 0 0 0 0 0 0 ------- ЭТО СТРОКА 4 -------------------------- -------------------------------------------------- -------------
Посоветуйте, пожалуйста, как правильно заполнить, спасибо.
#include <iostream>
#include <vector>
#include <Windows.h>
#include <algorithm>
using namespace std;
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};
// for vector: 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 vector to screen with 2 ROWS, 3 COLUMNS
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 13; j++)
{
cout << myVector[i][j] << ' ';
}
cout << '\n';
}
system("Pause");
return 0;
}