标签:
//直接插入排序
void InsertSort(int A[], int n)
{
int i,j;
int temp;
for (i=0;i<n-1;i++)
{
temp=A[i+1];
j=i;
while (j>-1&&temp<A[j])
{
A[j+1]=A[j];
j--;
}
A[j+1]=temp;
}
}
//冒泡排序
void BubbleSort(int A[],int n)
{
int i, j, flag=1;
int temp;
for (i=1;i<n&&flag;i++)
{
flag=0;
for (j=0;j<n-i;j++)
{
if(A[j+1]<A[j])
{
flag=1;
temp=A[j+1];
A[j+1]=A[j];
A[j]=temp;
}
}
}
}
标签:
原文地址:http://www.cnblogs.com/Vae98Scilence/p/4382009.html