嘿嘿,大一的时候做的课设,是关于学生信息管理系统的,这个做得比较全,用c写的,可以升序,降序,文件的保存以及,学生信息的录入等等等等,放这儿仅供参考,有什么不对的地方,欢迎批评指出,哈哈!
#include
#include
#include
#define YES 1
#define NO 0
typedef struct
{
int num;
float math_score;
float engl_score;
float chin_score;
float phy_score;
float chem_score;
double aver_score;
double sum_score;
char sex;
}StudentDate;//学生基本信息
typedef struct student
{
char name[20];//学生姓名
StudentDate one;//学生其他信息
int rank;//成绩排名
struct student *next;
}Student, *List;
Student *createListHead(void);//创建链表的头
void menu(void);//主菜单
void sortList(Student *pHead);//排序链表
void readListWithFile(Student *pHead, char *file_name);//从文件中读取数据,并保存在链表中
int userChioce(Student *pHead);//用户选择
int sortMenu(void);//打印选择菜单
void addStudentInfo(Student *pHead);//向链表的末尾添加数据
int scanMenu(void);//浏览菜单
void findStudentInfo(Student *pHead);//查找学生信息
void delStudentInfo(Student *pHead);//删除某一个学生信息
void alterStudentInfo(Student *pHead);//修改学生信息
void saveList(Student *pHead);//将链表保存在文件里
void printList(Student *pHead);//打印链表
void statisStudentInfo(Student *pHead);//查看学生信息
int statisMenu(void);//查看菜单
void inputData(Student *pHead,Student *node);//输入信息
int adMenu(void);
int main(void)
{
Student *pHead;
pHead = createListHead();//读取信息
while (1)
{
if (9 == userChioce(pHead)) //按9时退出系统
{
break;
}
}
return 0;
}
void menu(void)
{
system("CLS");//清屏
printf("\n\n\n\t\t\t\t┌─────────────────┐\n");
printf("\t\t\t\t│ 学生成绩统计系统 │\n");
printf("\t\t\t\t├─────────────────┤\n");
printf("\t\t\t\t│ 1 增加学生信息 │\n");
printf("\t\t\t\t├─────────────────┤\n");
printf("\t\t\t\t│ 2 删除学生信息 │\n");
printf("\t\t\t\t├─────────────────┤\n");
printf("\t\t\t\t│ 3 修改学生信息 │\n");
printf("\t\t\t\t├─────────────────┤\n");
printf("\t\t\t\t│ 4 查找学生信息 │\n");
printf("\t\t\t\t├─────────────────┤\n");
printf("\t\t\t\t│ 5 查看学生成绩 │\n");
printf("\t\t\t\t├─────────────────┤\n");
printf("\t\t\t\t│ 6 排序学生成绩 │\n");
printf("\t\t\t\t├─────────────────┤\n");
printf("\t\t\t\t│ 9 退出系统 │\n");
printf("\t\t\t\t├─────────────────┤\n");
printf("\t\t\t\t│ 制作人:xxxxxxxxxx \n");
printf("\t\t\t\t└─────────────────┘\n");
}
Student *createListHead(void)
{
Student *pHead;
pHead = (List)malloc(sizeof(Student));
pHead->next = NULL;
return pHead;
}
void readListWithFile(Student *pHead, char *file_name)
{
FILE *fp;
Student *p1, *p2;
int count, rank = 0;
StudentDate txt;
char stu_name[20];
fp = fopen(file_name, "r");
if (fp == NULL)
{
fp = fopen(file_name, "w");
fclose(fp);
return;
}
fseek(fp, 0L, 2);
count = ftell(fp);
p1 = pHead;
fp = fopen(file_name, "r");
while (!feof(fp))
{
p2 = (List)malloc(sizeof(Student));
fscanf(fp, "%d%s %c%f%f%f%f%f\n", &p2->one.num, p2->name, &p2->one.sex, &p2->one.chin_score,
&p2->one.math_score, &p2->one.engl_score, &p2->one.chem_score, &p2->one.phy_score);
p2->one.sum_score = (double)(p2->one.chin_score + p2->one.chin_score + p2->one.engl_score +
p2->one.chem_score + p2->one.phy_score);
p2->one.aver_score = p2->one.sum_score / 5;
p2->next = NULL;
p1->next = p2;
p1 = p2;
if (ftell(fp) == count)
{
break;
}
}
//将链表排序,并初始化排名
for (p1 = pHead->next; p1 != NULL; p1 = p1->next)
{
for (p2 = p1->next; p2 != NULL; p2 = p2->next)
{
if (p2->one.sum_score > p1->one.sum_score)
{
txt = p2->one;
strcpy(stu_name, p2->name);
p2->one = p1->one;
strcpy(p2->name, p1->name);
p1->one = txt;
strcpy(p1->name, stu_name);
}
}
p1->rank = ++rank;
}
fclose(fp);
}
void sortList(Student *pHead)
{
Student *p1, *p2;
StudentDate txt;
char stu_name[20];
int bum, count = 0, rank;
system("title 学生成绩统计系统-排序");//将标题栏命名为“学生成绩统计系统”
bum = sortMenu();
if (bum == 1) //按成绩升序
{
for (p1 = pHead->next; p1 != NULL; p1 = p1->next)
{
for (p2 = p1->next; p2 != NULL; p2 = p2->next)
{
if (p2->one.sum_score < p1->one.sum_score)
{
txt = p2->one;
rank = p2->rank;
strcpy(stu_name, p2->name);
p2->one = p1->one;
p2->rank = p1->rank;
strcpy(p2->name, p1->name);
p1->one = txt;
p1->rank = rank;
strcpy(p1->name, stu_name);
}
}
}
}
else if (bum == 2)//按学号升序
{
for (p1 = pHead->next; p1 != NULL; p1 = p1->next)
{
for (p2 = p1->next; p2 != NULL; p2 = p2->next)
{
if (p2->one.num < p1->one.num)
{
txt = p2->one;
rank = p2->rank;
strcpy(stu_name, p2->name);
p2->one = p1->one;
p2->rank = p1->rank;
strcpy(p2->name, p1->name);
p1->one = txt;
p1->rank = rank;
strcpy(p1->name, stu_name);
}
}
}
}
else if (bum == 3) //按成绩降序
{
for (p1 = pHead->next; p1 != NULL; p1 = p1->next)
{
for (p2 = p1->next; p2 != NULL; p2 = p2->next)
{
if (p2->one.sum_score > p1->one.sum_score)
{
txt = p2->one;
rank = p2->rank;
strcpy(stu_name, p2->name);
p2->one = p1->one;
p2->rank = p1->rank;
strcpy(p2->name, p1->name);
p1->one = txt;
p1->rank = rank;
strcpy(p1->name, stu_name);
}
}
}
}
else if (bum == 4)//按学号降序
{
for (p1 = pHead->next; p1 != NULL; p1 = p1->next)
{
for (p2 = p1->next; p2 != NULL; p2 = p2->next)
{
if (p2->one.num > p1->one.num)
{
txt = p2->one;
rank = p2->rank;
strcpy(stu_name, p2->name);
p2->one = p1->one;
p2->rank = p1->rank;
strcpy(p2->name, p1->name);
p1->one = txt;
p1->rank = rank;
strcpy(p1->name, stu_name);
}
}
}
}
else if(bum==5)
return;
else {
printf("\n输入错误,请重新输入;");
bum = sortMenu();
}
printList(pHead);
printf("敲任意数回到主菜单");
getch();
}
void printList(Student *pHead)
{
pHead = pHead->next;
system("CLS");
printf("\n\n ┏━━━┳━━━━┳━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━┓");
printf("\n ┃ 学号 ┃ 姓 名 ┃性别┃语 文┃高 数┃英 语┃C 语言┃大 物┃平均分┃总 分┃名次┃\n");
while (pHead)
{
printf(" ┣━━━╋━━━━╋━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━┫\n");
printf(" ┃ %-5d┃ %-6s ┃ %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", pHead->one.num,
pHead->name, pHead->one.sex, pHead->one.chin_score, pHead->one.math_score,
pHead->one.engl_score, pHead->one.chem_score
, pHead->one.phy_score, pHead->one.aver_score, pHead->one.sum_score, pHead->rank);
pHead = pHead->next;
}
printf(" ┗━━━┻━━━━┻━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━┛\n");
getch();
}
int userChioce(Student *pHead)
{
int bum;
system("title 学生成绩统计系统-主菜单");//将标题栏命名为“学生成绩统计系统”
menu();
printf("请按键选择: ");
bum = (int)(getch() - '0');
switch (bum)
{
case 1:
addStudentInfo(pHead);
break;
case 2:
delStudentInfo(pHead);
break;
case 3:
alterStudentInfo(pHead);
break;
case 4:
findStudentInfo(pHead);
break;
case 5:
statisStudentInfo(pHead);
break;
case 9:
break;
case 6:
sortList(pHead);
break;
default:
break;
}
return bum;
}
int sortMenu(void)
{
int bum;
system("CLS");
printf("\n\n\n");
printf("\t\t┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
printf("\t\t┃ 以什么方式排序 ? ┃\n");
printf("\t\t┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n");
printf("\t\t┃ 1 按成绩升序 ┃\n");
printf("\t\t┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n");
printf("\t\t┃ 2 按学号升序 ┃\n");
printf("\t\t┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n");
printf("\t\t┃ 3 按成绩降序 ┃\n");
printf("\t\t┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n");
printf("\t\t┃ 4 按学号降序 ┃\n");
printf("\t\t┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n");
printf("\t\t┃ 5 返回主菜单 ┃\n");
printf("\t\t┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n");
printf("请按键选择:");
bum = (int)(getch() - '0');
system("CLS");
return bum;
}
void addStudentInfo(Student *pHead)
{
FILE *fp;
Student *p1, *p2, *p3 = pHead;
StudentDate txt;
int judge = YES, rank = 0;
char bum, stu_name[20];
system("title 学生成绩统计系统-添加");//将标题栏命名为“学生成绩统计系统”
fp = fopen("stud.txt", "a");
while (pHead->next)
{
pHead = pHead->next;
}
while (judge)
{
p1 = (List)malloc(sizeof(Student));
inputData(p3,p1);
p1->next = NULL;
pHead->next = p1;
pHead = p1;
fprintf(fp, "%d %s %c %.1f %.1f %.1f %.1f %.1f\n", p1->one.num, p1->name, p1->one.sex, p1->one.chin_score,
p1->one.math_score, p1->one.engl_score, p1->one.chem_score, p1->one.phy_score);
printf("是否继续添加?(Y/N)");
bum = getch();
if (bum == 'n' || bum == 'N')
{
break;
}
}
//并交换排名
for (p1 = p3->next; p1 != NULL; p1 = p1->next)
{
for (p2 = p1->next; p2 != NULL; p2 = p2->next)
{
if (p2->one.aver_score > p1->one.aver_score)
{
txt = p2->one;
strcpy(stu_name, p2->name);
p2->one = p1->one;
strcpy(p2->name, p1->name);
p1->one = txt;
strcpy(p1->name, stu_name);
}
}
p1->rank = ++rank;
}
fclose(fp);
printf("\n敲任意数回到主菜单");
getch();
}
int scanMenu(void)
{
int bum;
system("CLS");
printf("\n\n\n");
printf("\t\t┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
printf("\t\t┃ 以什么方式? ┃\n");
printf("\t\t┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n");
printf("\t\t┃ 1 按学生的学号 ┃\n");
printf("\t\t┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n");
printf("\t\t┃ 2 按学生的姓名 ┃\n");
printf("\t\t┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n");
printf("\t\t┃ 3 按学生的名次 ┃\n");
printf("\t\t┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n");
printf("\t\t┃ 4 返回主菜单 ┃\n");
printf("\t\t┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n");
printf("请按键选择:");
bum = (int)(getch() - '0');
system("CLS");
return bum;
}
int adMenu(void)
{
int bum;
system("CLS");
printf("\n\n\n");
printf("\t\t┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
printf("\t\t┃ 以什么方式? ┃\n");
printf("\t\t┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n");
printf("\t\t┃ 1 按学生的学号 ┃\n");
printf("\t\t┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n");
printf("\t\t┃ 2 按学生的姓名 ┃\n");
printf("\t\t┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n");
printf("\t\t┃ 3 返回主菜单 ┃\n");
printf("\t\t┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n");
printf("请按键选择:");
bum = (int)(getch() - '0');
system("CLS");
return bum;
}
void findStudentInfo(Student *pHead)
{
int bum, count = 0;
int num;
char student_name[20];
int student_rank;
pHead = pHead->next;
system("title 学生成绩统计系统-查找");//将标题栏命名为“学生成绩统计系统”
bum = scanMenu();
if (bum == 1)
{
printf("请输入学生的学号:");
scanf("%d", &num);
while (pHead)
{
if (pHead->one.num == num)
{
if (count == 0)
{
printf("\n\t\t\t已经查到!\n");
printf("\n\n\n\n ┏━━━┳━━━━┳━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━┓");
printf("\n ┃ 学号 ┃ 姓 名 ┃性别┃语 文┃高 数┃英 语┃C 语言┃大 物┃平均分┃总 分┃名次┃\n");
count = 1;
}
printf(" ┣━━━╋━━━━╋━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━┫\n");
printf(" ┃ %-5d┃ %-6s ┃ %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", pHead->one.num,
pHead->name, pHead->one.sex, pHead->one.chin_score, pHead->one.math_score,
pHead->one.engl_score, pHead->one.chem_score
, pHead->one.phy_score, pHead->one.aver_score, pHead->one.sum_score, pHead->rank);
break;
}
pHead = pHead->next;
}
if (pHead == NULL)
{
printf("\n\t\t\t没有该学生记录!\n");
}
else
{
printf(" ┗━━━┻━━━━┻━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━┛\n");
}
}
if (bum == 2)
{
printf("请输入学生姓名:");
scanf("%s", student_name);
while (pHead)
{
if (strcmp(student_name, pHead->name) == 0)
{
if (count == 0)
{
printf("\n\t\t\t已经查到!\n");
printf("\n\n\n\n ┏━━━┳━━━━┳━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━┓");
printf("\n ┃ 学号 ┃ 姓 名 ┃性别┃语 文┃高 数┃英 语┃C 语言┃大 物┃平均分┃总 分┃名次┃\n");
count = 1;
}
printf(" ┣━━━╋━━━━╋━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━┫\n");
printf(" ┃ %-5d┃ %-6s ┃ %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", pHead->one.num,
pHead->name, pHead->one.sex, pHead->one.chin_score, pHead->one.math_score,
pHead->one.engl_score, pHead->one.chem_score
, pHead->one.phy_score, pHead->one.aver_score, pHead->one.sum_score, pHead->rank);
}
pHead = pHead->next;
}
if (count == 0)
{
printf("\n\t\t\t没有该学生记录!");
}
else
{
printf(" ┗━━━┻━━━━┻━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━┛\n");
}
}
if (bum == 3)
{
printf("请输入学生名次:");
scanf("%d",&student_rank);
while (pHead)
{
if (student_rank == pHead->rank)
{
if (count == 0)
{
printf("\n\t\t\t已经查到!\n");
printf("\n\n\n\n ┏━━━┳━━━━┳━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━┓");
printf("\n ┃ 学号 ┃ 姓 名 ┃性别┃语 文┃高 数┃英 语┃C 语言┃大 物┃平均分┃总 分┃名次┃\n");
count = 1;
}
printf(" ┣━━━╋━━━━╋━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━┫\n");
printf(" ┃ %-5d┃ %-6s ┃ %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", pHead->one.num,
pHead->name, pHead->one.sex, pHead->one.chin_score, pHead->one.math_score,
pHead->one.engl_score, pHead->one.chem_score
, pHead->one.phy_score, pHead->one.aver_score, pHead->one.sum_score, pHead->rank);
}
pHead = pHead->next;
}
if (count == 0)
{
printf("\n\t\t\t没有该学生记录!");
}
else
{
printf(" ┗━━━┻━━━━┻━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━┛\n");
}
}
if (bum == 4)
{
return;
}
printf("\n敲任意数回到主菜单");
getch();
}
void delStudentInfo(Student *pHead)
{
Student *p1, *p2 = pHead;
int bum;
int num;
char student_name[20], c;
system("title 学生成绩统计系统-删除");//将标题栏命名为“学生成绩统计系统”
bum = adMenu();
if (bum == 1)
{
p1 = pHead->next;
printf("\n\t\t\t请输入要删除学生的学号:");
scanf("%d", &num);
while (p1)
{
if (p1->one.num == num)
{
printf("\n\t\t\t删除成功,删除的学生学号为:%d", num);
if (p1->next == NULL)
{
pHead->next = NULL;
break;
}
else
{
pHead->next = p1->next;
free(p1);
p1 = pHead->next;
}
}
else if(p1->one.num != num)
{
pHead = pHead->next;
p1 = pHead->next;
printf("\n\t\t\t没有该学生信息!");
}
saveList(p2);
}
}
else if (bum == 2)
{
p1 = pHead->next;
printf("\n\t\t\t请输入要删除的学生姓名:");
scanf("%s", student_name);
while (p1)
{
if (strcmp(p1->name, student_name) == 0)
{
printf("\n\t\t\t删除成功,姓名为: %s", student_name);
if (p1->next == NULL)
{
pHead->next = NULL;
break;
}
else
{
pHead->next = p1->next;
free(p1);
p1 = pHead->next;
}
}
else if(strcmp(p1->name, student_name) != 0)
{
pHead = pHead->next;
p1 = pHead->next;
printf("\n\t\t\t没有该学生信息!");
}
saveList(p2);
}
}
else if (bum == 3)
{
return;
}
printf("\n敲任意数回到主菜单");
getch();
}
void saveList(Student *pHead)
{
FILE *fp;
fp = fopen("stud.txt", "w+");
pHead = pHead->next;
while (pHead)
{
fprintf(fp, "%d %s %c %.1f %.1f %.1f %.1f %.1f\n", pHead->one.num, pHead->name, pHead->one.sex, pHead->one.chin_score,
pHead->one.math_score, pHead->one.engl_score, pHead->one.chem_score, pHead->one.phy_score);
pHead = pHead->next;
}
fclose(fp);
}
void alterStudentInfo(Student *pHead)
{
int bum, count = 0, j = 0;
int num;
char student_name[20];
Student *p1 = pHead->next;
system("title 学生成绩统计系统-修改");//将标题栏命名为“学生成绩统计系统”
bum = adMenu();
if (bum == 1)
{
printf("\n\t\t\t请输入要修改学生的学号:");
scanf("%d", &num);
while (p1)
{
j++;
if (p1->one.num == num)
{
inputData(pHead,p1);
break;
}
p1 = p1->next;
}
if (p1 == NULL)
{
getch();
printf("没有该学生信息!");
}
}
else
{
if (bum == 2)
{
printf("\n\t\t\t请输入要修改学生的姓名:");
scanf("%s", student_name);
while (p1)
{
j++;
if (strcmp(p1->name, student_name) == 0)
{
inputData(pHead,p1);
count = 1;
}
p1 = p1->next;
}
if (count == 0)
{
printf("\n\t\t\t没有该学生信息!");
getch();
}
}
else
{
if (3 == bum)
{
return;
}
else
{
alterStudentInfo(pHead);
}
}
}
saveList(pHead);
printf("\n敲任意数回到主菜单");
getch();
}
void statisStudentInfo(Student *pHead)
{
double aver_score[5] = {0,0,0,0,0};
Student *p1 = pHead->next;
int count = 0;
int bum;
system("title 学生成绩统计系统-查看");//将标题栏命名为“学生成绩统计系统”
bum = statisMenu();
if (bum == 1)
{
while (p1)
{
aver_score[0] = aver_score[0] + p1->one.chin_score;
aver_score[1] = aver_score[1] + p1->one.math_score;
aver_score[2] = aver_score[2] + p1->one.engl_score;
aver_score[3] = aver_score[3] + p1->one.chem_score;
aver_score[4] = aver_score[4] + p1->one.phy_score;
p1 = p1->next;
count++;
}
aver_score[0] = aver_score[0] / count;
aver_score[1] = aver_score[1] / count;
aver_score[2] = aver_score[2] / count;
aver_score[3] = aver_score[3] / count;
aver_score[4] = aver_score[4] / count;
p1 = pHead->next;
printf("\n\n ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
printf(" ┃ 学号 ┃ 姓 名 ┃性别┃语 文┃高 数┃英 语┃C 语言┃大 物┃平均分┃总 分┃名次┃\n");
printf(" ┣━━━╋━━━━╋━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━━╋━━┫\n");
while (p1)
{
printf(" ┃ %-5d┃ %-6s ┃ %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", p1->one.num,
p1->name, p1->one.sex, p1->one.chin_score, p1->one.math_score,
p1->one.engl_score, p1->one.chem_score
, p1->one.phy_score, p1->one.aver_score, p1->one.sum_score, p1->rank);
p1 = p1->next;
}
printf(" ┗━━━┻━━━━┻━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━┛\n");
}
else
{
if (bum == 2)
{
return;
}
}
printf("\n敲任意数回到主菜单");
getch();
}
int statisMenu(void)
{
int bum;
system("CLS");
printf("\n\n\n");
printf("\t\t┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");
printf("\t\t┃ 1 显示学生成绩 ┃\n");
printf("\t\t┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫\n");
printf("\t\t┃ 2 返回主菜单 ┃\n");
printf("\t\t┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n");
printf("请按键选择:");
bum = (int)(getch() - '0');
system("CLS");
return bum;
}
void inputData(Student *pHead,Student *node)
{
Student *p1 = node,*p2,*p3 = pHead;
system("CLS");
printf("\t注意:姓名不能有空格,性别男用m表示,女用w表示,\n\t各科成绩应该大于0小于100,输入数据时请用空格隔开\n");
printf("\n\n\t请依次输入学生的学号、姓名、性别、语文、高数、英语、C语言、大物成绩\n");
scanf("%d%s %c%f%f%f%f%f", &p1->one.num, p1->name, &p1->one.sex, &p1->one.chin_score, &p1->one.math_score,&p1->one.engl_score, &p1->one.chem_score, &p1->one.phy_score);
p2 = p3->next;
while (1)
{
if (p1->one.sex != 'w'&& p1->one.sex != 'm')
{
p1->one.sex = getchar();
printf("性别输入不合法,请重新输入: ");
p1->one.sex = getchar();
}
else
{
break;
}
}
while (1)
{
if (p2 == NULL)
{
break;
}
if (p2->one.num == p1->one.num && p2 != node)
{
printf("该学号已存在,请重新输入学号:");
scanf("%d", &p1->one.num);
p2 = p3->next;
}
else
{
p2 = p2->next;
}
}
p1->one.sum_score = (double)(p1->one.chin_score + p1->one.chin_score + p1->one.engl_score +p1->one.chem_score + p1->one.phy_score);
p1->one.aver_score = p1->one.sum_score / 5;
}