#include <iostream>
using namespace std;
float func(int m, int n, float a[])
{
int i,j;
float max=0;
for (i=0;i<m;i++)
{
for (j=0;j<n;j++)
{
if (max<a[i][j]) max=a[i][j];
}
}
return max;
}
int main()
{
int i,j,m,n;
cin>>m>>n;
float a[m][n];
for (i=0;i<m;i++)
{
for (j=0;j<n;j++)
{
cin>>a[i][j];
}
}
cout<<func(m,n,a);
}
|
float a[m][n];float a[1000][1000];. The only limitation here is that m and n need to be below 1000. |
|
I would say that your problem is in this line:
You can't create an array with regular variables for the size. My suggestion is to use
Or maybe:
|
new keyword.new you'll need to delete it after!