<h2 style="margin: 0px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; color: blue; text-rendering: optimizeLegibility; font-size: 24px; line-height: 36px;">题目描述</h2><div class="content" style="background: none 0px 0px repeat scroll rgb(228, 240, 248); font-family: "Times New Roman"; font-size: 14px; line-height: 24px; height: auto; margin: 0px; padding: 0px 20px; color: rgb(51, 51, 51);"><div>快速排序是对起泡排序的一种改进。它的基本思想是,通过一趟排序将待排序的记录分割成两个独立的部分,其中一部分记录的关键字均比另一部分的关键字小,在分成两个部分之后则可以分别对这两个部分继续进行排序,从而使整个序列有序。</div><div>快速排序的算法可以描述如下:</div><div><img src="http://coder.buct.edu.cn:8088/JudgeOnline/upload/201405/pimg1777_1.png" width="599" height="502" alt="" style="height: auto; border: 0px; vertical-align: middle;" /></div><div>在本题中,读入一串整数,将其使用以上描述的快速排序的方法从小到大排序,并输出。</div><p style="margin-top: 0px; margin-bottom: 9px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px;"></p></div><h2 style="margin: 0px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; color: blue; text-rendering: optimizeLegibility; font-size: 24px; line-height: 36px;">输入</h2><div class="content" style="background: none 0px 0px repeat scroll rgb(228, 240, 248); font-family: "Times New Roman"; font-size: 14px; line-height: 24px; height: auto; margin: 0px; padding: 0px 20px; color: rgb(51, 51, 51);"><p style="margin-top: 0px; margin-bottom: 9px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px;">输入的第一行包含1个正整数n,表示共有n个整数需要参与排序。其中n不超过100000。 第二行包含n个用空格隔开的正整数,表示n个需要排序的整数。</p></div><h2 style="margin: 0px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; color: blue; text-rendering: optimizeLegibility; font-size: 24px; line-height: 36px;">输出</h2><div class="content" style="background: none 0px 0px repeat scroll rgb(228, 240, 248); font-family: "Times New Roman"; font-size: 14px; line-height: 24px; height: auto; margin: 0px; padding: 0px 20px; color: rgb(51, 51, 51);"><p style="margin-top: 0px; margin-bottom: 9px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px;">只有1行,包含n个整数,表示从小到大排序完毕的所有整数。 请在每个整数后输出一个空格,并请注意行尾输出换行。</p></div><h2 style="margin: 0px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; color: blue; text-rendering: optimizeLegibility; font-size: 24px; line-height: 36px;">样例输入</h2><div class="content" style="background: none 0px 0px repeat scroll rgb(228, 240, 248); font-family: "Times New Roman"; font-size: 14px; line-height: 24px; height: auto; margin: 0px; padding: 0px 20px; color: rgb(51, 51, 51);"><span class="sampledata" style="background: none 0px 0px repeat scroll rgb(141, 184, 255); font-family: monospace; font-size: 18px; white-space: pre;">102 8 4 6 1 10 7 3 5 9</span></div><h2 style="margin: 0px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; color: blue; text-rendering: optimizeLegibility; font-size: 24px; line-height: 36px;">样例输出</h2><div class="content" style="background: none 0px 0px repeat scroll rgb(228, 240, 248); font-family: "Times New Roman"; font-size: 14px; line-height: 24px; height: auto; margin: 0px; padding: 0px 20px; color: rgb(51, 51, 51);"><span class="sampledata" style="background: none 0px 0px repeat scroll rgb(141, 184, 255); font-family: monospace; font-size: 18px; white-space: pre;">1 2 3 4 5 6 7 8 9 10 </span></div>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<malloc.h>
#include<cmath>
#include<algorithm>
using namespace::std;
int m;
int n;
struct stu{
int num,len,wid;
}s[10005];
bool comp(stu a,stu b){
if(a.num!=b.num)
return a.num<b.num;
else if(a.num==b.num&&a.len!=b.len)
return a.len<b.len;
else
return a.wid<b.wid;
}
int main(){
while(~scanf("%d",&n)){
int i,j;
while(n--){
scanf("%d",&m);
int a,b,c;
for(i=0;i<m;i++){
scanf("%d %d %d",&a,&b,&c);
s[i].num=a;
if(b>=c){
s[i].len=b;
s[i].wid=c;
}
else{
s[i].len=c;
s[i].wid=b;
}
}
sort(s,s+m,comp);
cout<<s[0].num<<" "<<s[0].len<<" "<<s[0].wid<<endl;
for(i=1;i<m;i++){
if(s[i].num==s[i-1].num&&s[i].len==s[i-1].len&&s[i].wid==s[i-1].wid)
continue;
cout<<s[i].num<<" "<<s[i].len<<" "<<s[i].wid<<endl;
}
}
}
return 0;
}