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 32 33 34 35 36 37 38
|
#include<iostream.h>
#include<conio.h>
using namespace std;
#define ROW_COUNT 3
#define COL_COUNT 4
int BiggestEntry( int arr[ROW_COUNT][COL_COUNT], int row_count, int col_count );
// what about " two parameters representing the row and column"?
void main()
{
int a, b, x[ROW_COUNT][COL_COUNT] =
{
12,32,43,5,
1,14,25,60,
16,23,67,97
};
int max = BiggestEntry(x, ROW_COUNT, COL_COUNT);
cout << "Biggest entry is = " << max << endl;
getch();
}
int BiggestEntry(int arr[ROW_COUNT][COL_COUNT], int row_count, int col_count)
{
int row, col, Biggest;
Biggest = arr[0][0];
for (row = 0; row < row_count; row++)
for (col = 0; col < col_count; col++)
if (arr[row][col] > Biggest)
Biggest = arr[row][col];
return Biggest;
}
|