nyoj +set的使用重写了排序函数

来源:互联网 发布:微课制作软件下载 编辑:程序博客网 时间:2024/04/29 23:11
点击打开链接
#include<iostream>#include<stdio.h>#include<stdlib.h>#include<string>#include<cstring>#include<string.h>#include<set>#include<algorithm>using namespace std;struct Node{int num, len, wid;};set<Node>s;bool operator<(Node x, Node y){return  x.num<y.num || x.num == y.num && x.len<y.len || x.num == y.num&&x.len == y.len &&x.wid<y.wid;}int main(){int n, m, a, b, c;scanf("%d", &n);while (n--){scanf("%d", &m);while (m--){scanf("%d%d%d", &a, &b, &c);Node temp;if (b<c){temp.num = a, temp.len = c, temp.wid = b;s.insert(temp);}else{temp.num = a, temp.len = b, temp.wid = c;s.insert(temp);}}set<Node>::iterator it;for (it = s.begin(); it != s.end(); it++){printf("%d %d %d\n",it->num,it->len,it->wid);}s.clear();}return 0;}

                                             
0 0
原创粉丝点击