#include <iostream>using namespace std;int main(){int i,j,l,a[4][4]; for(i=0;i<3;i++)for(j=0;j<4;j++)cin>>a[i][j];for(i=0;i<3;i++)for(j=0;j<4;j++){for(l=0;l<4;l++)if((l!=j&&a[i][l]<=a[i][j])||(l!=i&&a[i][j]>=a[l][i]))break;if(l<4)continue;cout<<"["<<i<<"]"<<"["<<j<<"]="<<a[i][j]<<"is Saddle Point";}cout<<"No Saddle Point"; return 0;}
2 回答
已采纳
流走
TA贡献7条经验 获得超0个赞
#include <iostream> #include<algorithm> using namespace std; int main() { int i, j, l, a[4][4]; for (i = 0; i<3; i++) for (j = 0; j<4; j++) cin >> a[i][j]; for (i = 0; i<3; i++) for (j = 0; j<4; j++) { if (a[i][j] == max(max(max(a[i][0], a[i][1]), a[i][2]), a[i][3]) && a[i][j] == min(min(a[0][j], a[1][j]), a[2][j]))//找行最大和列最小 { cout << "[" << i << "]" << "[" << j << "]=" << a[i][j] << "is Saddle Point"; } } cout << "No Saddle Point"; return 0; }
你试试看。如果个数很多的话自己写个函数就行了。
- 2 回答
- 0 关注
- 1077 浏览
添加回答
举报
0/150
提交
取消