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
|
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
const int ColMax=5;
double MatrixMax (const double A[][ColMax],int,int);
int main()
{
const int RowSize=4,ColSize=5;
double A[RowSize][ColSize] = {{16,22,99,4,18}, //Row 1
{-258,4,101,5,98},//Row 2
{105,6,15,2,45}, //Row 3
{33,88,72,16,3}}; //Row 4
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) << A[Row][Col];
cout << endl;
}
cout << "Max value in matrix = " << Maximum << endl;
return 0;
}
double MatrixMax(const double A[][ColMax],int R, int C, int% RowR, int& ColR)
{
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;}
|