设为首页 加入收藏

TOP

2011年计算机等级考试二级C语言辅导实例编程(17)
2014-10-28 19:30:06 来源: 作者: 【 】 浏览:145
Tags:2011年 计算机 等级考试 二级 语言 辅导 实例 编程

  单链表冒牌排序


  今天做链表排序有个误区,就是以为交换的时候要连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->data=a[i];


  18 phead->next=NULL;


  19 ptr=phead->next;


  20 pre=phead;


  21 for(i=1;i


  编辑特别推荐:


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇2011年计算机等级考试二级C语言辅.. 下一篇2011年计算机等级考试二级C语言辅..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: