A sort time limit: theMs | Memory Limit:65535KB Difficulty:3
-
-
Descriptive narrative
-
Now there are very many rectangles. Each rectangle has a number, which can be repeated. Also know that the width and length of the rectangle, numbering, length, width are integers; now requires a sort of order (the default collation is small to large);
1. According to the number from small to large sort
2. For rectangles with equal numbers, according to the long sort of rectangles;
3. Assuming the number and length are the same, according to the width of the rectangle sort;
4. Assuming the number, length, and width are the same, just keep a rectangle for sorting and delete the extra rectangles. The final sequence displays all the rectangles in the specified format;
-
-
Input
-
-
the first line has an integer 0<n<10000, which indicates that there is an n set of test data next;
The first line of each group has an integer 0<m<1000, which indicates that there is a m rectangle;
The next M-line. Each line has three numbers, the first number represents the number of rectangles,
The second and third numeric representations are long, the values are small, the representation is wide, equal
Description This is a square (data contract length-width and number are less than 10000).
-
-
Output
-
-
Sequential output number length width of all eligible rectangles for each set of data
-
-
Example input
-
-
181 1 11 1 11 1 21 2 11 2 22 1 12 1 22 2 1
-
-
Example output
-
-
1 1 11 2 11 2 22 1 12 2 1
-
-
Source
Classic Topics
#include <stdio.h> #include <algorithm>using namespace std;struct st{int xh;int c,k;} Data[1010];int CMP (ST A,st B)//sequencing key! {if (A.XH!=B.XH) return A.xh<b.xh;else if (A.C!=B.C) return A.c<b.c;else if (A.K!=B.K) return A.K<B.K;} int main () {int test,i,n,t;scanf ("%d", &test), while (test--) {scanf ("%d", &n), and for (i=0;i<n;i++) {scanf ("%d%d %d ", &data[i].xh,&data[i].c,&data[i].k);//Note the longer and wider the size. if (DATA[I].C<DATA[I].K) {t=data[i].c;data[i].c=data[i].k;data[i].k=t;}} Sort (data,data+n,cmp); for (i=0;i<n;i++) {if (!) ( DATA[I].XH==DATA[I+1].XH&&DATA[I].C==DATA[I+1].C&&DATA[I].K==DATA[I+1].K)) printf ("%d%d%d\n", DATA[I].XH,DATA[I].C,DATA[I].K);}} return 0;}
A sort (nyoj8) (Simple sort)