#include<stdio.h>
/*
01 构建链表
02 初始化链表 注意头节点 直接赋值
03 输出链表
*/
struct stu{
int num;
float score;
struct stu *next;
};
void PX(struct stu a,struct stu b,struct stu c,struct stu *head)
{
head = &c;
c.next = &b;
b.next=&a;
a.next=NULL;
do{
printf("student number: %d score:%f\n",head->num, head->score);
head = head->next; //head->next = head
}while(head);
}
int main(){
struct stu a,b,c,d, *head;
a.num =1;
a.score = 89;
b.num = 2 ;
b.score = 98;
c.num = 3;
c.score = 99;
PX(a,b,c,head);
return 0;
}
abc三个数实现前插其余若为已知量可就此类推
最新推荐文章于 2024-05-28 16:13:50 发布