#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
struct date{
int x;
int y;
int z;
}three[50005];
bool cmp(date a,date b)
{
if(a.x == b.x){
if(a.y == b.y)return a.z<b.z;
else return a.y<b.y;
}return a.x<b.x;
}
int main()
{
int t;
scanf("%d",&t);
while(t--){
int line,i;
scanf("%d",&line);
for (i = 0;i < line;i ++)
scanf("%d %d %d",&three[i].x,&three[i].y,&three[i].z);
sort(three,three+i,cmp);
printf("%d\n",line);
for (i = 0;i < line;i ++)
printf("%d %d %d\n",three[i].x,three[i].y,three[i].z);
}
return 0;
}
不得不说在C++中快速排列真的是方便
只需要合理利用sort就行了。
cmp后面的括号中是定义一个相同类型的两个变量,在对变量的操作,返回自己想要的值。
并且sort(首地址,要排列的数量 ,cmp自己定义的函数)
typedef的使用还是有点问题的。