标题:[求助]链表.??
取消只看楼主
起点线
Rank: 1
等 级:新手上路
帖 子:107
专家分:0
注 册:2006-12-7
 问题点数:0 回复次数:0 
[求助]链表.??
这是链表的的个插入函数,看了半天都不明白函数里面的 q 起了什么作用.
大侠告诉下啊.麻烦尽量说详细点哦..! 一共出现了两次..

S *add(S *head,S *new)
{
S *p,*q,*head;
p=q=head;
if(head==0)
{ head=new; new->next=0 return head; };
else
while((new->num>p->num)&&(p->next!=0)
{ q=p; p=p->next; }
if(new->num<p->num)
{
if(p==head) { head=new; new->next=p; }
else { q->next=p->next new->next=p; }
}
else
{ p->next=new; new->next=0;}
return head;
}
2007-05-15 02:35



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




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

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