logo CodeStepByStep logo

crossSum

Language/Type: C++ Grid collections
Related Links:

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.

Function: Write a C++ function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.