#include"stdio.h"
voidSort(inta[],intn); //自定义的冒泡排序函数;
intmain()
{
inta[]={2,31,12,43,654,65,35,676,765,111};
intn=sizeof(a)/sizeof(a[0]);
inti;
for(i=0;i<n;i++)
printf("%3d ",a[i]);
printf("\n");
Sort(a, n); /////调用冒泡排序函数,参数a为数组名,n为数组长度;
for(i=0;i<n,i++)
printf("%3d ",a[i]);
printf("\n");
return0;
}
voidSort(inta[],intn)
{
inti,j,flag,t;
for(j=n-1;j>=1;j--)
{
flag=1;
for(i=0;i<j;i++)
if(a[i]>a[i+1])
{
flag=0;
t=a[i];
a[i]=a[i+1];
a[i+1]=t;
}
if(flag)
break;
}
return;
}