#include#include using namespace std; vector > matrix = {{1,2,3}, {4,5,6}, {7,8,9}}; int main() { int rowNumber = 1; // retrieve second row vector row = matrix[rowNumber]; for (int i = 0; i < row.size(); i++) { cout << row[i] << " "; } cout << endl; return 0; }
#includeThis code modifies the first value of the second row in a 3x3 matrix and prints the updated row to the console. The library used in this code is the standard C++ vector library.#include using namespace std; vector > matrix = {{1,2,3}, {4,5,6}, {7,8,9}}; int main() { int rowNumber = 1; matrix[rowNumber][0] = 10; // change the first value of row 2 to 10 for (int i = 0; i < matrix[rowNumber].size(); i++) { cout << matrix[rowNumber][i] << " "; } cout << endl; return 0; }