This program enables me to find the biggest number of all rows and columns and the overall highest number. How can I convert this exact code to a function of maxs() ? HELP PLEASE
#include<iostream>
using namespace std;
int main()
{
const int numrows=4;
const int numcols=5;
int maxs[numrows][numcols]={{12, 23, 6 , 34, 5},
{61, 9, 14, 54, 10},
{3, 21, 5, 67, 44},
{21, 89,13, 49, 90}};
int row,col,largestrows,largestcols,largest;
for(row=0;row<numrows;row++)
{
largestrows=maxs[row][0];
for(col=1;col<numcols;col++)
if(largestrows<maxs[row][col])
largestrows=maxs[row][col];
cout<<"The largest integer in the row"<<row+1<<" "<< "is "<<largestrows<<endl;
}
for(col=0;col<numcols;col++)
{
largestcols=maxs[0][col];
for(row=1;row<numrows;row++)
if(largestcols<maxs[row][col])
largestcols=maxs[row][col];
cout<<"The largest integer in the column"<<col+1<<" "<< "is "<<largestcols<<endl;
}
if(largestrows>largestcols)
largest=largestrows;
else
largest=largestcols;
cout<<"The largest integer of all data is "<<largest<<endl;
return 0;
}