int len = sizeof(arr) / sizeof(int);
void bubbleSort(int* arr, int len) //int * arr 也可以写为int arr[]
{
for (int i = 0; i < len – 1; i++)
{
for (int j = 0; j < len – 1 – i; j++)
{
if (arr[j] > arr[j + 1])
{
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}
原创文章,作者:745907710,如若转载,请注明出处:https://blog.ytso.com/245288.html