标签:
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<string.h> #include<algorithm> using namespace std; struct record { int bian; int chang; int kuan; }num[1100]; int min(int a,int b) { if(a>b) a=b; return a; } int max(int c,int d) { if(c<d) c=d; return c; } bool cmp(record e,record f) { if(e.bian!=f.bian) return e.bian<f.bian; else if(e.chang!=f.chang) return e.chang<f.chang; else if(e.kuan!=f.kuan) return e.kuan<f.kuan; //else return 0; } int main() { int n,m,j,i,s,sum,t,x,y; scanf("%d",&n); while(n--) { scanf("%d",&m); for(i=0;i<m;i++) { scanf("%d%d%d",&num[i].bian,&x,&y); num[i].chang=max(x,y); num[i].kuan=min(x,y); } sort(num,num+m,cmp); for(i=0;i<m;i++) { if(num[i].bian==num[i+1].bian&&num[i].chang==num[i+1].chang&&num[i].kuan==num[i+1].kuan) continue; printf("%d %d %d\n",num[i].bian,num[i].chang,num[i].kuan); } } return 0; }
标签:
原文地址:http://www.cnblogs.com/tonghao/p/4510296.html