功能:
1.设计保存学生信息的链表
2. 可随时添加学生信息,将新加入的学生信息按学号顺序添加到链表中
3. 设计遍历输出函数
3. 设计查找函数,根据学号查找或姓名查找
5. 可随时删除学生信息,根据学号删除
#include"stdio.h"
#include"stdlib.h"
/*typedef struct student{
int num;
char name[20];
int score;
struct student *next;
}STU;*/ //用这一段的话struct student类型可用STU代替达到简写的作用
struct student{ //定义一个结构体student
int num;
char name[20];
int score;
struct student *next;
};
struct Node{ //结构体链表定义
struct student data;
struct Node* next;
};
struct Node* creat_list(){ //创建一个链表的head结点
struct Node* headNode=(struct Node*)malloc (sizeof(struct Node));
headNode->next=NULL;
return headNode;
}
struct Node* creat_Node(struct student data){ //把student对象转为链表的结点,好处是模板化,假如对象不是一个student类型只需要在这里改下就可以了
struct Node* newNode=(struct Node*)malloc(sizeof(struct Node));
newNode->data=data;
newNode->next=NUL