找出二维数组的“鞍点”

//找出一个二维数组的“鞍点”,即该位置上的元素在该行上最大,在该列上最小。也可能没有鞍点。
 
//(1)二维数组有鞍点:
 int a[3][4]={{9,80,205,40},{90,-60,96,1},{210,-3,101,89}};
 
 //(2)二维数组没有鞍点:
 int b[4][4]={{9,80,205,40},{90,-60,196,1},{210,-3,101,89},{45,54,156,7}};
 
 AnDian(a, 3);
 AnDian(b, 4);
 
/*
查找鞍点函数
注意:二维数组作参数,一定要给出列的维度
*/
void AnDian(int arr[][4], int len)
{
 int i, j, k;
 int rowMaxIndex, iRAn=-1, iCAn=-1, iAn=-1;
 int iTemp;
 bool bAn = true;
 
 printf("\n---------------------------------\n\n");
 for (i=0; i arr[k][rowMaxIndex])
   {    
    bAn = false;
    break;
   }   
  } 
  if (bAn)
  {
   iRAn = i;
   iCAn = rowMaxIndex;
   iAn = iTemp;
  }
 }// for (i=0; i

Comments are closed.