#include<iostream> using namespace std; int arr[]={11,12,51,23,64,23,68,1,12}; void bubbleSort(int arr[]){ for (int i=0; i<9; i++){ for (int j=0; j<8-i; j++) if (arr[j]>arr[j+1]) swap(arr[j], arr[j+1]); } } int main() { bubbleSort(arr); for (int i=0; i<9; i++) cout<<arr[i]<<" "; }
时间: 2024-10-16 20:19:26