链表问题
来源:互联网 发布:学c语言转java容易吗 编辑:程序博客网 时间:2024/04/28 03:19
几年前就把谭浩强老师的《C语言设计》看完了,但对结构体是一知半解,自认为掌握了,现在学《C算法》时发现才没有直正了解。
# include <stdlib.h>
typedef struct node * link;
struct node
{
int item;
link next;
}
main ()
{
int i,N=9,M=5;
float a;
link t=malloc(sizeof *t),x=t;
t->item=1;
t->next=t;
for (i=2;i<=N;i++)
{
x=(x->next=malloc(sizeof * x));
x->item=i;
x->next=t;
}
while(x!=x->next)
{
for (i=1;i<M;i++)x=x->next;
x->next=x->next->next;
N--;
}
printf ("%d/n",x->item);
}
这是书中的源代码。开始我没有理解 x=(x->next=malloc(sizeof * x));
后来才知道这里的x和x->next指针(地址)。
- 链表问题
- 链表问题
- 链表问题
- C 链表问题
- 链表相交问题
- 链表问题
- 链表相交问题
- 链表问题总结
- 链表问题
- 链表相交问题
- 链表相交问题
- 链表问题
- 链表相交问题
- 循环链表问题
- 链表问题
- 链表排序问题
- 链表问题
- 链表问题(OJ)
- 南斯拉夫联盟共和国,1999年5月7日晚(北京时间5月8日清晨)
- 有感本命年
- DELPHI设计数据库查询的几种方法
- 天气真的能影响心情!!!
- Eclipse 3.0 上配置JSP开发环境
- 链表问题
- 利用自定义事件实现不同窗体间的通讯 -- C#篇
- 和春天有个约会
- 蹦迪--我的黑白玫瑰~!
- 2005.4.16——灌给即将荒芜的5460计应962
- edit中只让输入数字跟相关符号
- 在edit中有选择的输入
- 。作品集。
- 2005年下半年的自考又结束了!