2x2 Matrix Multiply
hardQuestion 548A 2x2 matrix is an array<array<int, 2>, 2>, where m[r][c] is the value in row r, column c.
Write a function array<array<int, 2>, 2> multiply(const array<array<int, 2>, 2>& a, const array<array<int, 2>, 2>& b) that returns the matrix product a x b.
The test prints the result as two lines, the two values in each row separated by a space. For a = {{1, 2}, {3, 4}} and b = {{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, so 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.