← Back to STL Containers
Question 548
2x2 Matrix Multiply
2x2 Matrix Multiply
A 2x2 matrix is anarray<array<int, 2>, 2>, wherem[r][c]is the value in rowr, columnc. Write a functionarray<array<int, 2>, 2> multiply(const array<array<int, 2>, 2>& a, const array<array<int, 2>, 2>& b)that returns the matrix producta x b. The test prints the result as two lines, the two values in each row separated by a space. Fora= {{1, 2}, {3, 4}} andb= {{5, 6}, {7, 8}} it prints the output shown in Expected Output. Do NOT write a main function.
Expected Output:
19 22 43 50 2 4 6 8
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
STL Containersstd::array
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.