且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C语言:实现链表插入10个数据

更新时间:2022-09-16 07:48:38

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

 

 

C语言:实现链表插入10个数据
#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; 

C语言:实现链表插入10个数据
本文转自施杨博客园博客,原文链接:http://www.cnblogs.com/shiyangxt/archive/2008/09/07/1286152.html,如需转载请自行联系原作者