鞍点

template<class Type>
void minmax(Type *s, int m, int n){
int *row=new Type[m], *col=new Type[n];
int i, j;
for (i=0; i<m; i++) {
row[i]=*(s+i*n);
for (j=0; j<n; j++)
if (row[i]>*(s+i*n+j)) row[i]=*(s+i*n+j); //行中最小
}
for (j=0; j<n; j++) {
col[j]=*(s+j*m);
for (i=0; i<m; i++)
if (col[j]<*(s+i*n+j)) col[j]=*(s+i*n+j); //列中最大
}
for (i=0; i<m; i++)
for (j=0; j<n; j++)
if (row[i]==col[j])
cout<<"The saddle point is at ("<<i<<", "<<j<<")./n";
delete []row;
delete []col;
}

你可能感兴趣的:(鞍点)