Write a function named crossSum
that accepts three parameters:
A reference to a Grid
of integers, and two integers for a row and column,
and returns the sum of all numbers in the row/column cross provided.
For example, if a grid named g
stores the following integers:
col 0 1 2
row
0 {{1, 2, 3},
1 {4, 5, 6},
2 {7, 8, 9}}
Then the call of crossSum(g, 1, 1)
should return (4+5+6+2+8) or 25
.
You may assume that the row and column passed are within the bounds of the grid.
Do not modify the grid that is passed in.