<span style="font-family: Arial, Helvetica, sans-serif;">//数组实现</span>
void ArrayBubbleSort (int a[],int n)
{
int i,j,t,tag = 1;
for(i = 1;i < n && tag;i++){
tag = 0;
for(j = n-1;j >= i;j--)
if(a[j-1] > a[j]){
t = a[j-1];
a[j-1] = a[j];
a[j] = t;
tag = 1;
}
}
}
//链表实现
typedef struct node{
int data;
struct node * next;
}ElemSN;
ElemSN * LinkBubbleSort(ElemSN *h)
{
//每次遍历找最大的
ElemSN *q,*p,*qm;//p q联动指针,qm为前驱指针,位置 qm,q,p
ElemSN *t = NULL;//t尾部岗哨,指向排在最前的不需交换的结点
//ElemSN *s;//交换中间变量
while(h->next - t){
//printf("%da ",h->data);
for(qm = NULL,q = h,p = q->next;p - t;qm = q,q = p,p = p->next)
if(q->data > p->