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

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; 

你可能感兴趣的:(C++,c,C#,D语言)