用鏈表表示的數據的簡單選擇排序結點的域為數據域data 指針域 next ;鏈表首指針為head 鏈表無頭結點
selectsort(head)
p=head;
while (p____()____)
{q=p; r=____()____
while(____()____)
{if (____()_____) q=r;
r=____()____;
}
tmp=q>data; q>data=p>data; p>data=tmp; p= ____()____;
}【南京理工大學 三 (分)】
.下面的c函數實現對鏈表head進行選擇排序的算法排序完畢鏈表中的結點按結點值從小到大鏈接請在空框處填上適當內容每個空框只填一個語句或一個表達式
#include <stdioh>
typedef struct node {char data; struct node *link; }node;
node *select(node *head)
{node *p*q*r*s;
p=(node *)malloc(sizeof(node));
p>link=head; head=p;
while(p>link!=null)
{q=p>link; r=p;
while (____()____)
{ if (q>link>data<r>link>data) r=q;
q=q>link;
}
if (____()____) {s=r>link; r>link=s>link; s>link= (____()_____); (____()_____);}
(____()____) ;
}
p=head; head=head>link; free(p); return(head);
} 【復旦大學 六(分)】
[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
From:http://tw.wingwit.com/Article/program/sjjg/201311/22994.html