logo CodeStepByStep logo


Language/Type: C++ Grid collections
Related Links:
Author: Marty Stepp (on 2016/06/16)

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
 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.

Type your C++ solution code here:

This is a function problem. Write a C++ function as described. Do not write a complete program; just the function(s) above.

You must log in before you can solve this problem.

Log In

Need help?

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.

© Marty Stepp, all rights reserved.