# include & ltmalloc.h & gt
Void ShowArr(int **a, int n)// output array
{
for(int I = 0; I & ltn;; i++)
{
Printf ("data %d", I+1);
for(int j = 0; j & ltn; j++)
printf("%d\t ",a[I][j]);
printf(" \ n ");
}
}
void Change_Find(int **a,int n)
{
int tmax=- 1,tmin = 1000;
int line_max=- 1,line_min=- 1,temp
for(int I = 0; I & ltn;; I++)// Find the maximum and minimum values.
{
for(int j = 0; j & ltn; j++)
{
if(a[I][j]& gt; tmax)
{
tmax = a[I][j];
line _ max = I;
}
if(a[I][j]& lt; tmin)
{
tmin = a[I][j];
line _ min = I;
}
}
}
Printf ("the line where the maximum value is located is %d, and the line where the minimum value is located is %d\n", line_max, line _ min);
for(int k = 0; k & ltn; k++)
{
temp = a[line _ max][k];
a[line _ max][k]= a[line _ min][k];
a[line _ min][k]= temp;
}
Printf ("The array after exchange is: \ n");
ShowArr(a,n);
}
int main()
{
int * * a;
int n=0,i=0,j;
Printf ("Please enter the number of rows n:");
scanf("%d ",& ampn);
/* A dynamic two-dimensional array is defined as follows */
a =(int * *)malloc(n * sizeof(int *)); //Apply for the first column
for(int I = 0; I & ltn;; i++)
{
a[I]=(int *)malloc(n * sizeof(int)); //Application line spacing
}
//Enter a two-dimensional array
for(I = 0; I & ltn;; i++)
{
Printf ("Please enter line %d \n", i+1);
for(j = 0; j & ltn; j++)
scanf("%d ",& ampa[I][j]);
}
Printf ("\ nYou entered: \ n");
ShowArr(a,n);
Change_Find(a,n);
fflush(stdin);
getchar();
}