I was going to create a function Swap() that swaps the two maximum elements of the n times m matrix A and matrix B.
But I'm having error: declaration of 'A' as multidimensional array must have bounds for all dimensions except the first
void Swap(int A[][], int B[][], int n, int m)
{
int max_A = A[0][0];
int max_B = B[0][0];
int index_Ai, index_Aj, index_Bi, index_Bj;
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
if(max_A < A[i][j])
{
max_A = A[i][j];
index_Ai = i;
index_Aj = j;
}
}
}
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
if(max_B < B[i][j])
{
max_B = B[i][j];
index_Bi = i;
index_Bj = j;
}
}
}
int temp;
temp = A[index_Ai][index_Aj];
A[index_Ai][index_Aj] = B[index_Bi][index_Bj];
B[index_Bi][index_Bj] = temp;
}
How should I deal with this problem? Or should I pass just two matrices as arguments and then find their sizes inside the funcion? Any help is appreciated.