*/
void BubbleSort(int arr[],int len)
{
int i,j,k,temp;
for (i = 0;i < len-1;i ++)
{
for (j = len-1;j > i;j --)
{
if (arr[j - 1] > arr[j])
{
temp = arr[j];
arr[j] = arr[j - 1];
arr[j - 1] = temp;
}
}
printf("第 %d 次排序结果为:",i + 1);
for (k = 0;k < len;k ++)
{
printf("%d ",arr[k]);
}
printf("\n");
}
}
原文地址:http://blog.csdn.net/sdgtliuwei/article/details/41911521