C语言大作业
学生信息管理系统
最最最基础带头节点的链表模板
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<string.h>
#define setup (StuList)malloc(sizeof(Student))
struct Grade {
float score;
};
typedef struct Student {
char sno[20];
char sname[20];
struct Grade Chinese, English, Math;
struct Student *next;
}Student, *StuList;
StuList CreateStuList(StuList head) {
//传参头节点指针
int tmp;
StuList p, tail;
head = (StuList)malloc(sizeof(Student));
head->sno[0] = '\0';
head->sname[0] = '\0';
(head->Chinese).score = 0;
(head->English).score = 0;
(head->Math).score = 0;
head->next = NULL;
tail = head; //链表为空时,头节点等于尾结点
int count;
printf("输入要加入的学生的人数:\n");
tmp = scanf("%d", &count);
if(tmp == 0) {
printf("输入错误!\n");
}
for(int i = 0; i < count; i++) {
printf("请输入第%d个学生信息:学号 姓名 语文成绩 英语成绩 数学成绩:\n", i + 1);
p = (StuList)malloc(sizeof(Student));
scanf("%s %s %f %f %f", &p->sno, &p->sname, &(p->Chinese).score, &(p->English).score, &(p->Math).score);
p->next = NULL;
tail->next = p;
tail = p;
}
return head;
}
StuList AddStuList(StuList student) {
printf("请输入要在哪个学号后面插入学生信息:\n");
char sno[20];
scanf("%s", sno);
StuList p = setup;
printf("请输入要插入的学生信息:学号 姓名 语文成绩 英语成绩 数学成绩:\n");
scanf("%s %s %f %f %f", &p->sno