未粘贴整个代码,问题仅在于排序功能 创建,必须对链接列表的元素进行排序。
Ex>输入(列表大小的5)> 9 8 7 5 3 输出> 3 5 7 8 9
struct node{
int info;
struct node *link;
};
struct node *START = NULL;
void sort(){//bubble sorting using temporary variable in linked list
int t;
struct node *t1;
struct node *t2;
for(t1=START;t1!=NULL;t1=t1->link){
for(t2=START;t2!=NULL;t2=t2->link){
if(t2->info=t2->link->info){
t=t2->info;
t2->info=t2->link->info;//info contains data
t2->link->info=t;//link contains the address of each node or link (next)
}
}
}