CJCoding With Joseph
15free / daySign inCreate account

Matrix to Stream

Write a function void printMatrix(ostream& out, const vector<vector<int>>& m) that writes each row of the matrix on its own line, with every value right-aligned in a field 4 characters wide (padded with spaces on the left) and nothing else between values. Each line ends with a newline.

Do NOT write a main function.

Expected Output:

   1   2
  10  20
 100   5  42
  -3   0   7

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Streamsostream
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.