#include <bits/stdc++.h>

using namespace std;

const int ARRAY_SIZE = 101;
int num_elements = 5; // 实际存储元素的数量
int arr[ARRAY_SIZE] = {0, 5, 3, 2, 8, 1}; // 从下标 1 开始使用,第一个元素不使用,这里仅为示例

int main() {
    // 使用 sort 函数对数组进行排序,注意起始和结束位置
    sort(arr + 1, arr + num_elements + 1); // 从 arr[1] 到 arr[num_elements] 排序

    // 输出排序后的数组元素
    for (int i = 1; i <= num_elements; ++i) {
        cout << arr[i] << " ";
    }
    cout << endl;

    return 0;
}


0 条评论

目前还没有评论...