#include<stdio.h>
/*
01 构建链表
02 初始化链表 注意头节点 直接赋值
03 输出链表
*/
struct stu{
int num;
float score;
struct stu *next;
};
int main(){
struct stu a, b, c, *head;
a.num =1;
a.score = 89;
b.num = 2 ;
b.score = 98;
c.num = 3;
c.score = 99;
head = &a;
a.next = &b;
b.next = &c;
c.next = NULL;
do{
printf("student number: %d score:%f\n",head->num, head->score);
head = head->next; //head->next = head
}while(head);
return 0;
}
C语言链表最简单实现(结构体过渡到链表)
最新推荐文章于 2023-06-28 15:19:21 发布