1.不做解释
#include <stdio.h>
void bubble_sort(int arr[],int sz)
{
int i = 0;
int j = 0;
int tmp = 0;
for(i = 0;i<sz-1;i++)
{
for(j = 0;j<sz-i-1;j++)
{
if(arr[j] < arr[j+1])
{
tmp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = tmp;
}
}
}
return 0;
}
int main()
{
int arr[] = {0,1,2,3,4,5,6,7,8,9};
int sz = sizeof(arr)/sizeof(arr[0]);
bubble_sort(arr,sz);
for(int i = 0;i<sz;i++)
{
printf("%d\n",arr[i]);
}
return 0;
}