题解 | #找最小数#

找最小数

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();
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务