Transpose a Matrix File
hardQuestion 595The 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, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
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.