CJCoding With Joseph
15free / daySign inCreate account

Transpose a Matrix File

The first line of the file holds two integers R C: the number of rows and the number of columns. The next R lines each hold C integers separated by single spaces:

2 3
1 2 3
4 5 6

Write a function void printTransposed(const string& filename) that prints the transpose: C lines, each containing R integers separated by single spaces with no trailing space, each line ending with a newline. Output line j lists column j of the input from top to bottom. For the file above print exactly the output shown in Expected Output.

Do NOT write a main function.

Expected Output:

1 4
2 5
3 6
7 8 9

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

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