1150:0 starting point Learning Algorithm 57--Program design Contest

Source: Internet
Author: User

1150:0 start-up algorithm 57--Program design contest time limit:1 Sec Memory limit:64 MB 64bit IO Format:%lld
submitted:1303 accepted:742
[Submit] [Status] [Web Board] Description

Every year in May, the province will hold a program design contest.
In order to get the best students to participate in the competition, we usually need to do a selection work.
Now you help the teacher to finish the task.

Input

Multiple sets of test data, one row per group of data, the first input an integer n (n <= 30), indicating the number of students enrolled in the selection. Then an n integer indicates the selection score.

Output

For each set of test data, output their scores on a line from high to low.

Sample Input
4 2 6 7 13 4 10 9

Sample Output
7 6 2 110 9 4

Source

0 Starting point Learning algorithm

1#include <stdio.h>2 intMain () {3     intn,a[ -];4      while(SCANF ("%d", &n)! =EOF) {5          for(intI=0; i<n;i++){6scanf"%d",&a[i]);7         }8         9          for(intI=0; i<n-1; i++){Ten             intk=i,t; One              for(intj=i+1; j<n;j++) A                 if(a[k]<A[j]) -k=J; -             if(k!=i) { thet=A[i]; -a[i]=A[k]; -a[k]=T; -             } +         } -          for(intI=0; i<n-1; i++) +printf"%d", A[i]); Aprintf"%d\n", a[n-1]); at     } -     return 0; -}

Choose the sorting Method!!!

1150:0 starting point Learning Algorithm 57--Program design Contest

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.