You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.4 KiB
57 lines
1.4 KiB
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
int main() {
|
|
//输入二维矩阵
|
|
int a[5][5] = {0};
|
|
for (int i = 0; i < 5; i++) {
|
|
for (int j = 0; j < 5; j++) {
|
|
cin >> a[i][j];
|
|
}
|
|
}
|
|
map<pair<int, int>, int> _map;
|
|
//找行的最大值
|
|
for (int i = 0; i < 5; i++) {
|
|
int max = INT32_MIN;
|
|
pair<int, int> _pair;
|
|
for (int j = 0; j < 5; j++) {
|
|
if (a[i][j] > max) {
|
|
max = a[i][j];
|
|
_pair = make_pair(i + 1, j + 1);
|
|
}
|
|
}
|
|
_map[_pair]++;
|
|
}
|
|
//找列的最小值
|
|
for (int j = 0; j < 5; j++) {
|
|
int min = INT32_MAX;
|
|
pair<int, int> _pair;
|
|
for (int i = 0; i < 5; i++) {
|
|
if (a[i][j] < min) {
|
|
min = a[i][j];
|
|
_pair = make_pair(i + 1, j + 1);
|
|
}
|
|
}
|
|
_map[_pair]++;
|
|
}
|
|
|
|
//输出结果
|
|
map<pair<int, int>, int>::iterator it;
|
|
it = _map.begin();
|
|
bool found = false;
|
|
while (it != _map.end()) {
|
|
if (it->second == 2) {
|
|
found = true;
|
|
cout << it->first.first << " " << it->first.second << " " << a[it->first.first - 1][it->first.second - 1]
|
|
<< endl;
|
|
break;
|
|
}
|
|
it++;
|
|
}
|
|
if (!found) {
|
|
cout << "not found" << endl;
|
|
}
|
|
return 0;
|
|
}
|