文章

16

粉丝

402

获赞

21

访问

148.2k

头像
比较容易理解的作法
P1159 清华大学上机题
发布于2020年3月26日 22:17
阅读数 10.7k

#include

using namespace std;

 

struct student {

    int p;

    int q;

};

bool compare (student x, student y){

    if (x.q == y.q)  return x.p < y.p;

    else return x.q < y.q;

}

int main(){

    int n;

    cin >> n;

    student all[n];

    for (int i = 0; i < n; i ++){

        cin >> all[i].p;

        cin >> all[i].q;

    }

    sort (all, all + n, compare);

    for (i...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发