1.建立一个如图所示的简单链表,它由三个学生数据的结点组成
代码:
#include
#include
#include
struct student
{
int num;//学号
char name[20];//姓名
double score;//成绩
struct student *next;//下一个结点地址
};
int main()
{
struct student *a,*b,*c,*head=NULL;
//建立四个结构体指针,其中head用来保存链表首地址,初始的NULL值表示还是一个空链表
a=malloc(sizeof(struct student));
//动态分配连续内存空间,长度为sizeof(struct student),并把起始地址赋给a
a->num=110011;
strcpy(a->name,"张三");
a->score=88.5;
b=malloc(sizeof(struct student));
b->num=110012;
strcpy(b->name,"李四");
b->score&