#include<stdio.h>
void bubbleSORT(int *a, int n)
{
int temp;
for (int i = 0; i < n; i++)
{
for (int j = n - 1; j > i; j--)
{
if (a[j] < a[j - 1])
{
temp = a[j];
a[j] = a[j - 1];
a[j - 1] = temp;
}
}
}
}
void main()
{
int a[] = { 10,6,5,2,3,8,7,4,9,1 };
int n = sizeof(a)/sizeof(int);
bubbleSORT(a, n);
for (int i = 0; i < n; i++)
{
printf("%d ", a[i]);
}
printf("\n");
}
冒泡排序
最新推荐文章于 2023-07-31 19:13:57 发布