冒泡排序與插入排序
{
unsigned int temp;
unsigned char i,j;
for( i=0; i for( j=i+1; j if( pArray[i]>pArray[j])
{
temp = pArray[i];
pArray[i]= pArray[j];
pArray[j]= temp;
}
}
void InsertSort(unsigned int *pArray,unsigned char arr_len)
{
unsigned int temp;
char i,j;
for( i=1; i {
temp=pArray[i];
j=i-1;
while((j>=0)&&(temp<=pArray[j]))
{
pArray[j+1]=pArray[j];
j--;
}
pArray[j+1]=temp;
}
}
評論