32. 降序排序

单点时限: 1.0 sec

内存限制: 256 MB

定义函数 Sort,对一个整数数组的元素按照降序进行排序。

#include <stdio.h>
#include <stdlib.h>

#define MAX 100

//********** Specification of Sort **********
void Sort(int *p, int n)
/* PreCondition:  p指向一个整数数组,n是范围为2-100的数组元素个数
    PostCondition: 按降序对数组进行排序
*/

{

}

/***************************************************************/
int main() {
    int n, i;
    int a[MAX];
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    Sort(a, n);
    for (i = 0; i < n; i++)
        printf("%d%c", a[i], i < n - 1 ? ' ' : '\n');
    return 0;
}

样例

Input
4
2018 -1 2017 2019
Output
2019 2018 2017 -1

398 人解决,424 人已尝试。

446 份提交通过,共有 1043 份提交。

1.4 EMB 奖励。

创建: 6 年,3 月前.

修改: 6 年,3 月前.

最后提交: 3 周,4 天前.

来源: 2017 程序设计基础期末考