#include<iostream> using namespace std; class BubbleSort { public: int* bubbleSort(int* A, int n) { // write code here //c++求数组长度:sizeof(array) / sizeof(array[0]) for (int i = 0; i<n; i++) for (int j = 0; j<n - i - 1; j++) { if (A[j]>A[j + 1]) { int temp = A[j]; A[j] = A[j + 1]; A[j + 1] = temp; } } return A; } }; int main() { int n = 10; int a[10]; for (int i = 0; i<n; i++) { cin >> a[i]; } BubbleSort b; b.bubbleSort(a, n); cout << "排好的数为:" << endl; for (int i = 0; i<n; i++) cout << a[i] << "\t"; cout << endl; system("pause"); return 0; }