标题:单链表应该怎么倒置啊
取消只看楼主
heqinwu8
Rank: 2
来 自:黄土高坡
等 级:论坛游民
帖 子:65
专家分:58
注 册:2009-7-11
结帖率:100%
 问题点数:0 回复次数:0 
单链表应该怎么倒置啊
struct tree
{int data;
struct tree *next;
};
void main()
{struct tree head,a,b,c,*p,*q,*i;
head.next=&a;a.data=1;
a.next=&b;b.data=2;
b.next=&c;c.data=3;
c.next=NULL;
p=head.next;
do
{printf("%d ",p->data);
p=p->next;
}while(p!=NULL);

q=&head;         //这里总是无限循环
while(q)
{i=q;
q=i->next;
q->next=head.next;
head.next=q;
}
应该怎么改啊,高手们帮帮忙
搜索更多相关主题的帖子: 倒置 单链 
2009-11-08 22:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-291540-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.290926 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved