1131: Sequence sort time limit:1 Sec Memory limit:128 MB
submit:316 solved:100
[Submit] [Status] [BBS] Description
Rearranges a positive integer sequence {k1,k2,..., K9} into a new sequence. In the new sequence, the number smaller than the K1 is in front of the K1 (left), and the number larger than K1 is behind the K1 (right).
Input
The input has more than one line, and the first behavior n represents the number of rows, 9 integers per line.
Output
Outputs n rows, sorted as required.
Sample Input26 8 9 1 2 5 4 7 33 5 8 9 1 2 6 4 7Sample Output3 4 5 2 1 6 8 9 72 1 3 5 8 9 6 4 7Hintsource
School of Software, Jishou University
I used the method is very stupid, also defined a lot of variables ....
1#include <stdio.h>2 intMain ()3 {4 intN;5scanf"%d",&n);6 while(n--)7 {8 inti,b[Ten],a[Ten],c[Ten];9 for(i=0; i<9; i++)Ten { Onescanf"%d",&a[i]); A } - intk=0, m=a[0]; - for(intj=1; j<9; J + +) the { - if(a[j]<a[0]) - { -b[k++]=A[j]; + } - } + for(i=k-1; i>=0; i--) A { atprintf"%d", B[i]); - } - intv=0; - for(intI=0; i<9; i++) - { - if(a[i]>=m) in { -c[v++]=A[i]; to } + } - for(i=0; i<v-1; i++) the { *printf"%d", C[i]); $ }Panax Notoginsengprintf"%d\n", c[v-1]); - } the}
Sort by series