标签:
1 8 1 1 1 1 1 1 1 1 2 1 2 1 1 2 2 2 1 1 2 1 2 2 2 1
1 1 1 1 2 1 1 2 2 2 1 1 2 2 1
#include <stdio.h>
#include <algorithm>
using namespace std;
struct node
{
int w,h,ans;
}a[1000];
bool cmp(node x,node y) //cmp函数的改写
{
if(x.ans<y.ans)
return true;
if(x.ans==y.ans&&x.h<y.h)
return true;
if(x.ans==y.ans&&x.h==y.h&&x.w<y.w)
return true;
return false;
}
int main()
{
int n,m,i;
scanf("%d",&n);
while(n--)
{
scanf("%d",&m);
for(i=0;i<m;i++)
{
scanf("%d%d%d",&a[i].ans,&a[i].h,&a[i].w);
if(a[i].h<a[i].w) //这里要注意先判断长和宽
swap(a[i].h,a[i].w);
}
sort(a,a+m,cmp);
printf("%d %d %d\n",a[0].ans,a[0].h,a[0].w);
for(i=1;i<m;i++) //控制输出,把相同的就不输出了
{
if(a[i].ans==a[i-1].ans&&a[i].h==a[i-1].h&&a[i].w==a[i-1].w)
continue;
printf("%d %d %d\n",a[i].ans,a[i].h,a[i].w);
}
}
return 0;
}标签:
原文地址:http://blog.csdn.net/sxx312/article/details/51333642