#include <stdio.h>
int main(int argc, const char * argv[])
{
int arr[] = {1,2,3,5,4,3,66,43,6,4,25,3};
int len = sizeof(arr)/sizeof(arr[0]);
for(int i = 0;i < len - 1;i++)
{
for(int j = 0;j < len - 1 - i;j++ )
{
if(arr[j] > arr[j+1])
{
arr[j] = arr[j] + arr[j+1];
arr[j+1] = arr[j] - arr[j+1];
arr[j] = arr[j] - arr[j+1];
}
}
}
for(int i = 0;i < len;i++)
{
printf("%d ",arr[i]);
}
printf("这个就是冒泡排序法\n"); |