Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.
typedef vector<int> Row;
typedef vector<Row> Matrix;
// Matrix is just an array (vector) of rows, where each row consists of an array of ints
int main() {
const int nRows = 64;
const int nCols = 48;
Matrix matrix1( 64, Row(48) );
// since the entire matrix is allocated, you can say use 2d indexing:
for( int k=0; k < nRows; ++k ) {
for( int j=0; j < nCols; ++j ) {
matrix1[k][j] = 2*k+j;
}
}
Matrix matrix2(64) ; // 64 rows defined; but each has no space yet
for( int i=0; i < nRows; ++i) {
for( int n=0; n < nCols; ++n ) {
matrix2[i].push_back(n+i);
}
}
}
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.