题解 | #找最小数#
找最小数
https://www.nowcoder.com/practice/ba91786c4759403992896d859e87a6cd
#include <algorithm>
#include <iostream>
#include<vector>
using namespace std;
struct Entity {
int x,y;
Entity() { cin >> x >> y; }
bool operator<(const Entity &other) const {
return this->x == other.x ? this->y < other.y : this->x < other.x;
}
void display() const {
cout << this->x << " " << this->y << endl;
}
};
int main() {
int n;
cin >> n;
vector<Entity> list(n);
min_element(list.begin(), list.end())->display();
}
查看8道真题和解析
腾讯成长空间 1159人发布