文章目录
- AcWing 818. 数组排序
- AC代码
AcWing 818. 数组排序
本题链接:AcWing 818. 数组排序
本博客给出本题截图:
AC代码
代码:
#include <iostream> using namespace std; void sort(int a[], int l, int r) { for (int i = l; i <= r; i ++ ) for (int j = i + 1; j <= r; j ++ ) if (a[j] < a[i]) swap(a[i], a[j]); } int main() { int a[1000]; int n, l, r; cin >> n >> l >> r; for (int i = 0; i < n; i ++ ) cin >> a[i]; sort(a, l, r); for (int i = 0; i < n; i ++ ) cout << a[i] << ' '; return 0; }