例题:简单链表
1 #include<stdio.h> 2 struct Student 3 { 4 int num; 5 float score; 6 struct Student *next; 7 }; 8 int main() 9 { 10 struct Student a,b,c,*head,*p; 11 a.num=10101;a.score=89.5; 12 b.num=10103;b.score=90; 13 c.num=10107;c.score=85; 14 head=&a; 15 a.next=&b; 16 b.next=&c; 17 c.next=NULL; 18 p=head; 19 do 20 { 21 printf("%ld%5.1f\n",p->num,p->score); 22 p=p->next; 23 }while(p!=NULL); 24 return 0; 25 }
浙公网安备 33010602011771号