您的位置:首页 > 其它

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

2015-10-21 16:01 281 查看
点击打开链接
#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;
}



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: