Arrays-max num location

I finally got this array set up but I need help modifying it to display the location (row & column) that the max number is in. Can anyone assist me with this?

Here is what I have:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

const int ColMax = 5;
double MatrixMax(const double[][ColMax],int,int);
int main ()
{
	int ColRow[2];
	const int RowSize = 4, ColSize = 5 ;
	double Values[RowSize][ColSize] = {{16,22,99,4,18},
									   {-258,4,101,5,98},
									   {105,6,15,2,45},
									   {33,88,72,16,3}};
	double Maximum = MatrixMax(Values,RowSize,ColSize);
	cout << "Contents of Matrix\n";
	for (int Row = 0; Row < RowSize; Row++)
	{	for (int Col = 0; Col < ColSize; Col++)
		cout << setw(6) << Values[Row][Col];
	cout << endl; }
cout << "Max Value in Matrix = " << Maximum << endl;

return 0;}

double MatrixMax(const double A[][ColMax], int R, int C)
{	double Max = A[0][0];
	for (int Row = 0; Row < R; Row++)
		for (int Col = 0; Col < C; Col++)
			if (A[Row][Col]>Max) Max = A[Row][Col];
	return Max;}
Whats wrong? I compiled and ran it and it works fine.
I'm trying to make the program display the row & column that the max number is in using the function.
1
2
3
4
5
6
double MatrixMax(const double A[][ColMax], int R, int C)
{	double Max = A[0][0];
	for (int Row = 0; Row < R; Row++)
		for (int Col = 0; Col < C; Col++)
			if (A[Row][Col]>Max) Max = A[Row][Col];
	return Max;}
Topic archived. No new replies allowed.