#include <stdio.h>
int BubbleSort(int A[], int n)
{
// 输入:数组A,元素数目n
// 输出:数组A中元素完成从小到大排序
int i, j, x;
for (i = 0; i < n - 1; i++)
//
for (j = 0; j < n - i - 1; j++)
if (A[j] > A[j + 1])
{
x = A[j];
A[j] = A[j + 1];
A[j + 1] = x;
// 互换A[j]和A[j+1]的值
}
return 1;
}
int main()
{
int a[10] = {3, 5, 6, 2, 1, 4, 0, 7, 9, 8};
BubbleSort(a, 10);
for (int i = 0; i < 10; i++)
{
printf("%d", a[i]);
}
}
标签:10,int,冒泡排序,BubbleSort,++,数组
From: https://www.cnblogs.com/chenrunun/p/17021723.html