Need desperate help with two dimensional array problem

• 05-10-2003
webvigator2k
Need desperate help with two dimensional array problem
I have ZERO clue how to do/what to do for this program. Can anyone help me out?
Write a program that inputs a two-dimensional array (you may use a data
file, but if you do, have main print out the array) consisting of 5 rows
and 4 columns of integers, and determines and prints the sum of the
entries in the row or column of the largest entry.

The program should have a function that finds the largest element of the
array and returns the row index and column index of the largest element.
(The function should do no more, and no less.)

Be sure not to add the largest element twice in calculating the sum.

For example: If the array is

2 1 0 3
-5 6 8 -10
0 0 1 2
5 19 3 15
-25 6 8 -50

the function should return 3 for the row index and 1 for the column index
(as 19 is the largest element of the array). The sum computed and printed
by main( ) would be the sum of the numbers in row index 3 or column
index 1: the sum of 5,19, 3, 15,1, 6, 0, 6, namely 55.

You may not use global variables.
Use the above example to test your program.
• 05-10-2003
jverkoey
Re: Need desperate help with two dimensional array problem
or you could just do:

Code:

```int mat[5] [4]= {         { 2, 1, 0, 3},         {-5, 6, 8, -10},         {0, 0, 1, 2},         {5, 19, 3, 15},         {-25, 6, 8 -50} };```
and then just run through the matrix that way..........
• 05-10-2003
webvigator2k
I dont understand how we're supposed to "select" the highest number array and add up it's column and row. this lady never taught us any of this \$\$\$\$, so if I seem clueless, it's because I am :mad:
• 05-10-2003
R.Stiltskin
The idea is for you to figure out how to solve that problem, not just recite someone else's solution.

Think about what you need to accomplish. Not only do you have to go through the array examining one element at a time to find the highest value (think of it as "highest-so-far"), but when you've finished doing that, you have to know exactly where it is in the array (row and column).

So, set up the appropriate three variables, and try to figure out what to do next.
• 05-10-2003
7stud
"this lady never taught us any of this \$\$\$\$"

Did she teach you what a for-loop, a while-loop, and an array are?
That's all you need to know. If she didn't teach you those things, get a good C++ book, like "Ivor Horton's Beginning C++", for a reference.