/* date:2014.12.13
Bubble sort idea: Exchange sort, through the comparison of adjacent data, exchange to achieve the purpose of sorting.
Process: 1). The data in the array, comparing the size of the adjacent two elements in turn;
2). If the previous data is larger than the subsequent data, the two data will be exchanged, after the first round of multiple comparisons sorted, the smallest (or maximum) data can be taken well;
3). Compare the remaining data one by one in the same way until (n-1) order.
Time complexity: Worst O (n^2), average O (n^2).
Space complexity: O (1).
is a stable sorting algorithm.
*/
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 ("The result of order%d is:", i + 1);
for (k = 0;k < Len;k + +)
{
printf ("%d", arr[k]);
}
printf ("\ n");
}
}
Bubble Sort algorithm