首页 > 代码库 > 数组-09. 求矩阵的局部极大值(15)

数组-09. 求矩阵的局部极大值(15)

 1 #include<iostream> 2 using namespace std; 3 int main(){ 4     int i,j,m,n,a[21][21]; 5     bool flag=true; 6     cin>>m>>n; 7     for(i=0;i<m;++i) 8         for(j=0;j<n;++j) 9             cin>>a[i][j];10     for(i=1;i<m-1;++i)11         for(j=1;j<n-1;++j)12             if(a[i][j]>a[i][j-1]&&a[i][j]>a[i][j+1]13                 &&a[i][j]>a[i-1][j]&&a[i][j]>a[i+1][j]){14                 cout<<a[i][j]<<" "<<i+1<<" "<<j+1<<endl;15                 flag=false;16             }17     if(flag)18         cout<<"None "<<m<<" "<<n<<endl;19     return 0;20 }