找寻鞍点

#include <stdio.h>
#include <stdlib.h>
#define m 4
#define n 5


/* 找寻鞍点 find the andian you can guess what */


int main(int argc, char *argv[]) {
int a[m][n];
int max,mj,flag;
int i,j,k;
printf("input the number :\n");
for(i=0;i<m;++i)
{
for(j=0;j<n;++j)
{
scanf("%d",&a[i][j]);// input of the array
}
}
for(i=0;i<m;++i)
{
max=a[i][0];
mj=0;
    for(j=0;j<n;j++)
    {
    if(a[i][j]>max)
    {
    max=a[i][j];
    mj=j;
    }
    }
    printf("第%d行的最大数为%d,其在第%d列\n",i,max,mj);// the largest number in the row 
    flag=1; // before the whole line 's circulation . and the second row can inherit the row 's flag value 
           //so every thing have done ,you finally can get a utimate flag value , which can be used to judge weather  the 
   // andian is exist. ^-^  
    for(k=0;k<m;k++)
    {
    
    if(a[k][mj]<max)
    {
    //printf("a[%d][%d]=%d\n",k,mj,a[k][mj]); 
    flag=0;
    continue; 
    }
   
    }
    if(flag)
    {
    printf("andian is a[%d][%d]=%d\n",i,mj,max); 
    break;
    }
    
}
if(!flag)
{
printf("it's not exist\n");

}
return 0;

}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值