#include using namespace std; const int N = 1e5 + 10; int n = 7; int a[N] = {12, 2, 14, 6, 7, 10, 8}; int main() { // 冒泡排序 for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - i - 1; j++) { if (a[j] > a[j + 1]) { swap(a[j], a[j + 1]); } } } // 输出一下 for (int i = 0; i < n; i++) { cout << a[i] << " "; } return 0; }