文章
1
粉丝
79
获赞
0
访问
5.5k
#include <iostream>
#include <vector>
using namespace std;
struct node{
int row;
int column;
int data;
bool is = true;
};
int main(){
int n,m;
cin >> n >> m;
int a[n][m];
for(int i = 0;i < n;i++){
for(int j = 0;j < m;j++){
cin >> a[i][j];
}
}
vector<node> result;//用于存放符合条件的点
//选出每行最大元素
int i;
for(i = 0;i < n;i++){
struct node info;
info.row = i;
info.column = 0;
info.data = a[i][0];
result.push_back(info);
int j;
int temp = a[i][0];
for(j = 1;j < m;j++){
if(temp < a[i][j]){
temp = a[i][j];
result[i].column = j;
result[i].data = a[i][j];
}else if(temp == a[i][j]){
struct node tmpNode;
tmpNode.row = i;
tmpNode.column = j;
tmpNode.data = a[i][j];
result.push_back(tmpNode);
}else{
continue;
}
}
}
//判断是否是最小值
for(int k = 0;k < result.size();k++){
i = result[k].row;
int j = re...
登录后发布评论
暂无评论,来抢沙发