|
![]() | 作者: newmyself [newmyself]
![]() |
登录 |
typedef struct lnode{ char ch; struct lnode *next; }list; /*** creat1 *****/ list *creat() { list *head,*p,*q; int n=0; p=q=(list *)malloc(sizeof(list)); head=NULL; scanf("%c",&p->ch); while(p->ch!='\n') { n++; if (n==1) head=p; else q->next=p; q=p; p=(list *)malloc(sizeof(list)); } q->next=NULL: return head; } /*** creat2 ***/ void creat(list *head) { list *p; p=(list *)malloc(sizeof(list)); scanf("%c",&p->ch); head->next=NULL: while(p->ch!='\n') { p->next=head->next; head->next=p; p=(list *)malloc(sizeof(list)); p->ch=getchar(); } } 这两个creat()有什么不同 ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
地主 发表时间: 05-03-17 11:42 |
![]() | 回复: SysHu0teR [syshunter] ![]() |
登录 |
第一个是是尾插法建立不带头节点的链表,第二个是用头插法建立带头节点的链表 |
B1层 发表时间: 05-03-17 18:11 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号