文章
28
粉丝
0
获赞
272
访问
9.4k
#include <iostream>
#include <vector>
using namespace std;
int main() {
//count用来检查是否有鞍点
int n, m, count = 0;
cin >> n >> m;
vector<vector<int> > matrix(n,vector<int>(m));
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
cin >> matrix[i][j];
for(int i = 0; i < n; i++){
//默认该行第一个元素为最大
int row_max = matrix[i][0];
//可能有多个最大值,因此用数组存储
vector<int> row_max_pos(1);
for(int j = 1; j < m; j++){
if(matrix[i][j] > row_max) {
//遇到新的最大值要清空row_max_pos数组
row_max = matrix[i][j];
row_max_pos.clear();
row_max_pos.push_back(j);
}else if(matrix[i][j] == row_max) {
row_max_pos.push_back(j);
}
}
//对每一个最大值进行检查
for(auto col : row_max_pos) {
bool flag = true;
int l = 0;
for(l; l < n; l++) if(matrix[l][col] < row_max) flag = false;
if(flag) {
cout << i+1 << ' ' << col+1 << ' ' << row_m...
登录后发布评论
暂无评论,来抢沙发