I need to swap the row that includes the maximal element with the column that includes the minimal element.

Here's my code with the mistake:

Code:

#include <stdio.h>
#include <stdlib.h>
int main()
{
int N;
int i, j, max, min, rowmax, colmin, temp;
printf("The size of array: ");
scanf("%u", &N);
int **arr = calloc(N, sizeof(int *));
for (int i = 0; i < N; ++i) {
arr = calloc(N, sizeof(int));
for (int j = 0; j < N; ++j) {
printf("array[%u][%u] = ", i, j);
scanf("%d", &arr[j]);
}
}
for (int i = 0; i < N; ++i) {
for (int j = 0; j < N; ++j)
printf("%d ", arr[j]);
printf("\n");
}
printf("\n");
for (int i = 0; i < N; ++i) {
for (int j = 0; j < N; ++j) {
if (arr[j] > max) {
max = arr[j];
arr[j] = arr[rowmax][j];
arr[rowmax][j] = max;
}
}
}
for (int i = 0; i < N; ++i) {
for (int j = 0; j < N; ++j) {
if (arr[j] < min) {
min = arr[j];
arr[j] = arr[colmin];
arr[colmin] = min;
}
}
}
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
temp = arr[j];
arr[j] = arr[rowmax][colmin];
arr[rowmax][colmin] = arr[colmin][rowmax];
arr[colmin][rowmax] = temp;
}
}
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++)
printf("%d ", arr[j]);
printf("\n");
}
return 0;
}