#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct student{
int id;
int height;
int weight;
};
bool compare(const student& a,const student& b){
if(a.height!=b.height){
return a.height < b.height;
}
else if(a.weight!=b.weight){
return a.weight < b.weight;
}
else{
return a.id<b.id;
}
}
int main() {
int n;
cin >> n;
vector<student> students(n);
for(int i = 0; i < n; i++){
cin >> students[i].height;
students[i].id = i+1;
}
for(int i = 0; i < n; i++){
cin >> students[i].weight;
}
sort(students.begin(),students.end(),compare);
for (int i = 0; i < students.size(); i++) {
cout << students[i].id;
if (i < students.size() - 1) { // 检查是否是最后一个元素
cout << " ";
}
}
cout << endl;
return 0;
}
按照身高体重排序(C++)
于 2024-05-06 17:27:03 首次发布