Menu
CoddyTech

反向排序

Coddy 冒泡排序 课程的第 8 课,共 11 课。

challenge icon

挑战

简单

创建一个名为 reverse_sort 的函数,接收一个数组和数组的大小。使用冒泡排序算法按降序排列数组。返回最终数组。

例如,

给定输入: [2,4,1,2,3]

n=5

输出: [4,3,2,2,1] 

亲手试试

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

int* reverse_sort(int* arr, int arr_size, int n, int* returnSize) {
    // 在这里编写代码
    *returnSize = n;
    return arr;
}

冒泡排序中的所有课

自己练习: C 在线编译器