//建立一个如图所示的简单链表,它由3个学生数据的结点组成,
//要求输出各结点中的数据。
#include "stdio.h"
struct student{
int num;
int score;
struct studet *next;
};
int main()
{
struct student a,b,c,*p,*head;
a.num=1;a.score=34;
b.num=2;b.score=56;
c.num=3;c.score=56;
head=&a;
a.next=&b;
b.next=&c;
c.next=NULL;
p=head;
do{
printf("%d,%d",p->num,p->score);
printf("\n");
p=p->next;
}while(p!=NULL);
/*for(p=head;p!=NULL;p=p->next){
printf("%d %d",p->num,p->score);
}*/
return 0;
}
静态链表
最新推荐文章于 2022-03-31 00:25:37 发布