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