2011年计算机等级考试二级C语言辅导实例编程(17)
文章作者 100test 发表时间 2011:03:17 20:48:13
来源 100Test.Com百考试题网
  单链表冒牌排序
  今天做链表排序有个误区,就是以为交换的时候要连next节点也交换,还要固定head节点,想了很久也没做出来,但是后来看网上的提示,才知道只要交换节点内的数据就可以了,根本不用交换next节点
  01 #include 
  02 #include 
  03
  04 struct node
  05 {
  06 int data.
  07 struct node *next.
  08 }.
  09
  10 struct node *create_list(int a[],int len)
  11 {
  12 struct node *phead.
  13 struct node *ptr.
  14 struct node *pre.
  15 phead=(struct node *)malloc(sizeof(struct node)).
  16 int i=0.
  17 phead-