Sort by series

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.