C语言链表的使用:仅供查阅!

 

 

#include<stdio.h> 
#include
<stdlib.h> 

typedef 
struct LNode 

int data; 
struct LNode *next; 
}LNode,
*Llist; 

LNode 
*creat_head();//创建一个空表 
void creat_list(LNode *,int);//创建一个长度为n的线性链表  
main() 

LNode 
*head,*p; 
int n=10
int x,i; 
int b; 
int clrscr(); 
head
=creat_head(); 
creat_list(head,n); 
for(p=head->next;p!=NULL;) 

printf(
"%d ",p->data); 
p
=p->next; 

}
//创建一个空链表 
LNode *creat_head() 

LNode 
*p;

p
=(Llist)malloc(sizeof(LNode)); 

p
->next=NULL; 

return(p); 

//创建一个长度为10的线性链表 
void creat_list(LNode *head,int n) 

LNode 
*p,*q; 
int i; 
p
=head; 
for(i=1;i<=n;i++

q
=(Llist)malloc(sizeof(LNode)); 
printf(
"data:");scanf("%d",&q->data); 
q
->next=NULL; 
p
->next=q; 
=q; 

相关文章:

  • 2021-07-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2021-09-01
  • 2022-02-21
相关资源
相似解决方案