function c=bubble_sort(a)% 冒泡算法% Written by Phillip Wan @ 2013.9.11% Email:hackerwanhappy@foxmail.comfor j=1:length(a)-1for i=1:length(a)-1if a(i)>a(i+1)test=a(i);a(i)=a(i+1);a(i+1)=test;endende
冒泡排序:--------------------------------------------------------- #include <stdio.h> #define SIZE 8 void bubble_sort(int a[], int n); void bubble_sort(int a[], int n) { int i, j, temp; for (
这里我写了一个测试demo,测试前面的冒泡排序、直接插入排序算法、快速排序算法、二路归并排序算法的性能: package leetcode.Algorithm;import java.util.Random;/*** Created by louyuting on 17/2/6.*/public class ClientTest {private static final int N = 8