写一个函数insert,用来向一个动态链表插入结点
#include <stdio.h>
#include <stdlib.h>
typedef struct Student {
long num;
float score;
struct Student* next;
} Student;
Student* creat(void) {
Student *head = NULL, *p1, *p2;
p1 = p2 = (Student*)malloc(sizeof(Student));
scanf("%ld,%f", &p1->num, &p1->score);
int n = 0;
while (p1->num != 0) {
n++;
if (n == 1) head = p1;
else p2->next = p1;
p2 = p1;
p1 = (Student*)malloc(sizeof(Student));
scanf("%ld,%f", &p1->num, &p1->score);
}
p2->next = NULL;
return head;
}
void print(Student* head) {
Student* p = head;
while (p != NULL) {
printf("Num: %ld, Score: %.1f\n", p->num, p->score);
p = p->next;
}
}
Student* insert(Student* head, Student* newStudent) {
S