CJCoding With Joseph
15free / daySign inCreate account

Ragged Row Table on the Heap

Read 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 — print one after the last line.

Hints4 available
Topics:
Pointers
📥 Auto-Input:
3\n3 1 2 3\n2 10 15\n1 7\n
This input is automatically fed to your program's stdin
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.