#include#include using namespace std; int main() { vector > matrix = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; // Accessing element at row 2, column 3 int element = matrix[1][2]; // Printing the matrix for (auto row : matrix) { for (auto col : row) { cout << col << " "; } cout << endl; } return 0; }
#includeusing namespace cv; int main() { Mat matrix = (Mat_ (3, 3) << 1, 2, 3, 4, 5, 6, 7, 8, 9); // Accessing element at row 2, column 3 int element = matrix.at (1, 2); // Printing the matrix cout << matrix << endl; return 0; }
#includeBy looking at the examples provided, it can be seen that Eigen library was used in the last example, OpenCV library was used in the second example, and STL library was used in the first example.#include using namespace Eigen; int main() { MatrixXi matrix(3, 3); matrix << 1, 2, 3, 4, 5, 6, 7, 8, 9; // Accessing element at row 2, column 3 int element = matrix(1, 2); // Printing the matrix cout << matrix << endl; return 0; }