C代码:
1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<malloc.h> 4 5 //创建简单静态链表 6 typedef struct node{ 7 int data; 8 struct node *next; 9 }Node,*pNode; 10 11 int main() 12 { 13 pNode Head,p; 14 Node a,b,c; 15 a.data=1; 16 b.data=2; 17 c.data=3; 18 19 Head=&a; 20 a.next=&b; 21 b.next=&c; 22 c.next=NULL; 23 24 p=Head; 25 26 27 do 28 { 29 printf("%d ",p->data); 30 p=p->next; 31 } 32 while(p!=NULL); 33 return 0; 34 }
结果: