Ragged Row Table on the Heap
hardQuestion 478Read an integer n, the number of rows. Then, for each row, read its length k followed by that row's k integers. Store the rows as an int ** where row i is its own allocation of exactly k ints, and keep each row's length.
For each row print its values separated by single spaces, then a space, an equals sign, a space, and the row's sum. After all the rows, print Total, a space, an equals sign, a space, and the sum of every value in the table.
Sample input: 3 3 1 2 3 2 10 15 1 7
Free the memory you allocate before the program ends — this question checks for memory leaks.
Expected output
1 2 3 = 6 10 15 = 25 7 = 7 Total = 38
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Pointers
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (p, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.