NODE* bubblesort(NODE* Head)
{
NODE *pfirst=NULL,*psecond=NULL,*pend=NULL;
pfirst=Head;
psecond=Head;
int temp;
while(pfirst != pend) //外循环
{ //pfirst != pend 很有意思
while(pfirst->next != pend)//内循环
{
if(pfirst->date > pfirst->next->date)
{
temp=pfirst->date;
pfirst->date=pfirst->next->date;
pfirst->next->date=temp;
}
pfirst=pfirst->next;
}
pend=pfirst;//减少最后的已排好的循环
pfirst=Head;
}
return Head;
}
【无标题】链表冒泡排序
最新推荐文章于 2024-05-15 16:20:58 发布