C语言排序算法
冒泡排序###
C语言实现####
#include <stdio.h>
void bubble_sort(int a[], int n)
{
int i, j, temp;
for(j = 0;j < n - 1; j++)
{
for(i = 0; i < n - 1 - j; i++)
{
if(a[i] > a[i + 1])
{
temp = a[i];
a[i] = a[i + 1];
a[i + 1] = temp;
}
}
}
}
int main()
{
int number[8] = {95,45,15,78,84,51,24,12};
bubble_sort(number, 8);
for(int i = 0; i < 8; i++)
{
printf("%d ",number[i]);
}
}