从大一刚开学初登csdn,现在已是寒假假期过半,把最近刚完成不久的学生成绩管理系统给各位同学学习参考,另外由于本人才大一零基础入门学的C,若有错误纰漏之处还望见谅,也欢迎各位看官予以指正。这里还要特别感谢CSDN博主「photoer_coder」的原创文章,对本文章提供很多参考,也欢迎各位去学习参考他的文章,这是他的原文链接:https://blog.csdn.net/qq_41728697/article/details/80991027

/*************************************
*******程序名称:学生成绩管理系统
*******作    者:
*******开发环境:vs2019
*******创建日期:2022.01.21
*******完成日期:2022.01.27
**************************************/#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#include<windows.h>//system()函数;gotoxy()函数,在控制台中可以随意操控光标位置。
#include<ctype.h>//使用isprint()函数,检测所获字符是否可打印。#define YES 1
#define NO 0
typedef struct
{int id;float gaoshu;float yuwen;float yingyu;double aver_score;double sum_score;char sex;
}StudentDate;
typedef struct student
{StudentDate one;char name[20];int rank;struct student *next;
}Student, *List;Student* CreatListHead();                               //创建链表头
Student* startCheck();                                  //登录系统并初始化密码
void passwordCheck();                                   //密码判断
void correctWord();                                     //修改密码
void menu();                                            //主菜单(列出系统功能)
int scanMenu();                                         //查看、删除功能的选择菜单
int statisMenu();                                       //统计功能的菜单
int userChoice(Student *phead);                         //对主菜单的功能进行选择
void addStudentInfo(Student *phead);                    //添加学生信息(向链表末尾添加数据)(添加功能)
void inputData(Student *phead, Student *note);          //添加并检查录入信息是否正确
void delStudentInfo(Student *phead);                    //删除学生信息(删除功能)
void alterStudentInfo(Student *phead);                  //修改学生信息(修改功能)
void findStudentInfo(Student *phead);                   //查看学生信息(查看功能)
void statisStudentInfo(Student* phead);                 //统计学生信息(统计功能)
void readListWithFile(Student *phead, char *file_name); //从文件读取数据并保存到链表
void sortList(Student *phead);                          //对链表排序
void saveList(Student *phead);                          //将链表保存在文件中
void printList(Student *phead);                         //打印链表
void gotoxy(int x, int y);                              //操控光标位置int main()
{Student* pHead;HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);//得到窗口句柄SMALL_RECT rc = { 0, 0, 94 - 1, 30 - 1 };   //{Y位置,X位置,宽,高}SetConsoleWindowInfo(hOut, TRUE, &rc);// 重置窗口位置和大小,这里vs2019用大写字母的truesystem("color F1");//设置控制台颜色pHead = startCheck();//登录系统while (1){if (9 == userChioce(pHead)) //根据用户选择对主菜单的功能进行选择,按9时退出系统{break;}}return 0;
}
/*================================================
== 函数名:Student *startCheck()
== 功  能:登陆系统并初始化密码
== 参  数:无
== 返回值:链表的头指针
=================================================*/Student* startCheck()
{Student* pHead;FILE* fp1;char password[20] = "111111";int i;if ((fp1 = fopen("password.dat", "rb")) == NULL)//若密码文件不存在,新建密码文件{fp1 = fopen("password.dat", "wb");fwrite(password, 20, 1, fp1);//把1个大小为20字节的数据(这里指的是passward这个字符数组)写到fp1指向的文件fclose(fp1);printf("密码初始化完成!(默认密码为:111111)");}//读条system("CLS");system("title 学生成绩管理系统-载入中");//将标题栏命名为“学生成绩统计系统”printf("\n\n\t\t\t欢迎进入本系统!正在载入.....");printf("\n\n\n\n\t\t\t┏━━━━━━━━━━━━━━━━━━━━┓\n");printf("\t\t\t┃                    ┃\n");printf("\t\t\t┗━━━━━━━━━━━━━━━━━━━━┛\n");gotoxy(26, 7);for (i = 0; i < 10; i++){printf("█");Sleep(100);}pHead = CreatListHead();readListWithFile(pHead, "stud.dat");//从文件读取数据并保存到链表return pHead;
}
/*================================================
== 函数名:void passwordCheck()
== 功  能:密码输入及判定
== 参  数:无
== 返回值:无
=================================================*/
void passwordCheck()
{char password[20], inputword[20];int i = 1, j = 0;char c = 0;FILE* fp = fopen("password.dat", "rb");system("title 学生成绩管理系统-密码输入");fread(password, 20, 1, fp);//从fp指向的文件中读取出password这个数据for (i = 0; i < 3; i++){j = 0;if (i > 0){printf("\n\n\n\t\t你还有%d次机会输入正确密码: ", 3 - i);}printf("\n\n\n\n\t\t\t┏━━━━━━━━━━━━━━━━┓\n");printf("\t\t\t┃                ┃\n");printf("\t\t\t┗━━━━━━━━━━━━━━━━┛\n");gotoxy(26, 8);while ((c = _getch()) != 13 && j < 20)//使用的是getch函数,从键盘上获取一个字符,但不显示在屏幕上{if (c == '\b' && j > 0)//判断用户是否按退格键,'/b'+字符:会覆盖签一个字符{putchar('\b');putchar(' ');putchar('\b');j--;}else{if (isprint(c))//isprint为检测c是否为可打印的字符{putchar('*');inputword[j] = c;j++;}}}inputword[j] = '\0';if (strcmp(inputword, password) == 0){return;}else{system("CLS");printf("\t\t\t密码输入错误");}}if (3 == i){system("CLS");printf("\n\n\n\t\t你已浪费所有机会!程序即将退出!");Sleep(2000);exit(0);}fclose(fp);system("CLS");return;
}
/*================================================
== 函数名:Student *createListHead()
== 功  能:创建一个单链表,创建链表头
== 参  数:无
== 返回值:返回链表的头指针
=================================================*/
Student* CreatListHead()
{Student* pHead;pHead = (List)malloc(sizeof(Student));pHead->next = NULL;return pHead;
}
/*================================================
== 函数名:void readListWithFile(Student *pHead, char *file_name)
== 功  能:将文件内的信息读取到链表中,是登陆系统后将之前录入的数据数据读到链表里
== 参  数:Student *pHead:链表头指针char *file_name:文件指针
== 返回值:无
=================================================*/
void readListWithFile(Student* pHead, char* file_name)
{FILE* fp;Student* p1, * p2;int count, rank = 0;StudentDate dat;char stu_name[20];fp = fopen(file_name, "r");if (fp == NULL){fp = fopen(file_name, "w");fclose(fp);return;}fseek(fp, 0L, 2);//把位置指针移动到离文件结尾0字节处count = ftell(fp);//返回当前文件指针相对于文件开头的位移量p1 = pHead;fp = fopen(file_name, "r");while (!feof(fp))//判断文件指针是否到达文件末尾,是则feof函数返回非0值,反之返回0{p2 = (List)malloc(sizeof(Student));fscanf(fp, "%d %s %c %f %f %f\n", &p2->one.id, p2->name, &p2->one.sex, &p2->one.gaoshu,&p2->one.yuwen, &p2->one.yingyu);//从fp指向的文件中读取数据p2->one.sum_score = (double)(p2->one.gaoshu + p2->one.yuwen + p2->one.yingyu);p2->one.aver_score = p2->one.sum_score / 3;p2->next = NULL;p1->next = p2;//(p1==phead,故此处对链表第一组数据赋值)p1 = p2;if (ftell(fp) == count)//判断是否写到文件末尾{break;}}//将链表排序,并初始化排名(p1指向第一组数据,p2指向第二组数据)for (p1 = pHead->next; p1 != NULL; p1 = p1->next){for (p2 = p1->next; p2 != NULL; p2 = p2->next){if (p2->one.aver_score > p1->one.aver_score){dat = p2->one;strcpy(stu_name, p2->name);p2->one = p1->one;strcpy(p2->name, p1->name);p1->one = dat;strcpy(p1->name, stu_name);}}p1->rank = ++rank;}fclose(fp);
}
/*================================================
== 函数名:void menu()
== 功  能:菜单显示
== 参  数:无
== 返回值:无
=================================================*/
void menu()
{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│         7   修改登陆密码         │\n");printf("\t\t\t\t├──────────────────────────────────┤\n");printf("\t\t\t\t│         8      关于              │\n");printf("\t\t\t\t├──────────────────────────────────┤\n");printf("\t\t\t\t│         9    退出系统            │\n");printf("\t\t\t\t└──────────────────────────────────┘\n");
}
/*================================================
== 函数名:int userChioce(Student *pHead)
== 功  能:用户功能选择
== 参  数:链表头指针
== 返回值:功能对应整型数
=================================================*/
int userChioce(Student* pHead)
{int bum;system("title 学生成绩管理系统-主菜单");menu();printf("请按键选择: ");bum = (int)(_getch() - '0');switch (bum){case 1:printf("\n添加学生信息\n请输入密码:");passwordCheck();addStudentInfo(pHead);break;case 2:printf("\n删除学生信息\n请输入密码:");passwordCheck();delStudentInfo(pHead);break;case 3:printf("\n修改学生信息\n请输入密码:");passwordCheck();alterStudentInfo(pHead);break;case 4:findStudentInfo(pHead);break;case 5:statisStudentInfo(pHead);break;case 6:sortList(pHead);break;case 7:correctWord();break;case 8:MessageBox(NULL, TEXT("名称:学生成绩管理系统\n学校:岭南师范学院\n作者:21电气3 XXX"), TEXT("关于"), MB_OK);//设置弹窗(第二个参数是弹窗内容,第三个是标题)break;case 9:break;default:break;}return bum;
}/*================================================
== 函数名:void addStudentInfo(Student *pHead)
== 功  能:向链表末尾添加数据
== 参  数:链表头指针
== 返回值:无
=================================================*/
void addStudentInfo(Student* pHead)
{FILE* fp;Student* p1, * p2, * p3 = pHead;StudentDate dat;int judge = YES, rank = 0;char bum, stu_name[20];system("title 学生成绩管理系统-添加");fp = fopen("stud.dat", "a");while (pHead->next)//第一个while循环是使头指针指到链表末尾,才可以继续添加数据{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\n", p1->one.id, p1->name, p1->one.sex, p1->one.gaoshu,//这里是将我们刚才在inputDate里输入的数据写到fp所指向的文件p1->one.yuwen, p1->one.yingyu);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){dat = p2->one;strcpy(stu_name, p2->name);p2->one = p1->one;strcpy(p2->name, p1->name);p1->one = dat;strcpy(p1->name, stu_name);}}p1->rank = ++rank;}fclose(fp);
}
/*================================================
== 函数名:void inputData(Student *pHead, Student *node)
== 功  能:输入信息并检测是否合法
== 参  数:Student *pHead:链表头指针Student *node:链表工作指针
== 返回值:无
=================================================*/
void inputData(Student* pHead, Student* node)
{Student* p1 = node, * p2, * p3 = pHead;//指针node指向新申请的内存空间,此处将其赋给指针p1system("CLS");printf("\n\n\t请依次输入学生的学号、姓名、性别、高数、语文、英语\n");printf("\t注意:姓名不能有空格,性别男用M表示,女用W表示,\n\t各科成绩应该大于0小于100,输入数据时请用空格隔开\n");scanf("%d %s %c %f %f %f", &p1->one.id, p1->name, &p1->one.sex, &p1->one.gaoshu, &p1->one.yuwen, &p1->one.yingyu);// 判断输入的学号是否已经存在p2 = p3->next;while (1){if (p2 == NULL)//第一次添加数据,此时p2是phead->next,故为NULL,后边没有学号需要比对,故直接退出循环,进入下个循环{break;}if (p2->one.id == p1->one.id && p2 != node)//在上一个函数中此处的p1是新申请的内存块,现已录入数据,与前者对比信息。另外此处的p2!=node是用于修改信息时不需进入此步骤而设设立的{printf("该学号已存在,请重新输入学号:");scanf("%d", &p1->one.id);p2 = p3->next;}else{p2 = p2->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 (p1->one.gaoshu < 0 || p1->one.gaoshu  > 100){printf("高数成绩输入不合法,请重新输入:");scanf("%f", &p1->one.gaoshu);}if (p1->one.yuwen < 0 || p1->one.yuwen> 100){printf("语文成绩输入不合法,请重新输入:");scanf("%f", &p1->one.yuwen);}if (p1->one.yingyu < 0 || p1->one.yingyu > 100){printf("英语成绩输入不合法,请重新输入:");scanf("%f", &p1->one.yingyu);}if (p1->one.gaoshu >= 0 && p1->one.gaoshu <= 100 && p1->one.yuwen >= 0&& p1->one.yuwen <= 100 && p1->one.yingyu >= 0 && p1->one.yingyu <= 100){break;}}p1->one.sum_score = (double)(p1->one.gaoshu + p1->one.yuwen + p1->one.yingyu);p1->one.aver_score = p1->one.sum_score / 3;
}
/*================================================
== 函数名:int scanMenu()
== 功  能:查询菜单显示和选择
== 参  数:无
== 返回值:功能对应整型数
=================================================*/
int scanMenu()
{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 saveList(Student *pHead)
== 功  能:将链表保存在文件,主要是数据改动后保存信息
== 参  数:链表头指针
== 返回值:无
=================================================*/
void saveList(Student* pHead)
{FILE* fp;fp = fopen("stud.dat", "w+");pHead = pHead->next;while (pHead){fprintf(fp, "%d %s %c %.1f %.1f %.1f\n", pHead->one.id, pHead->name, pHead->one.sex, pHead->one.gaoshu,pHead->one.yuwen, pHead->one.yingyu);pHead = pHead->next;}fclose(fp);
}
/*================================================
== 函数名:void delStudentInfo(Student *pHead)
== 功  能:删除数据
== 参  数:链表头指针
== 返回值:无
=================================================*/
void delStudentInfo(Student* pHead)
{Student* p1, * p2 = pHead;int bum;int num, count = 0;char student_name[20], c;system("title 学生成绩管理系统-删除");//将标题栏命名为“学生成绩统计系统”bum = scanMenu();if (bum == 1){p1 = pHead->next;printf("\n\t\t\t请输入要删除学生的学号:");scanf("%d", &num);while (p1){if (p1->one.id == num){    count = 1;printf("\n\t\t\t删除成功,删除的学生学号为:%d,姓名为:%s,性别:%c", p1->one.id, p1->name,p1->one.sex);if (p1->next == NULL){pHead->next = NULL;break;}else{pHead->next = p1->next;free(p1);p1 = pHead->next;}}else{ pHead = pHead->next;p1 = pHead->next;}}}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){count++;}p1 = p1->next;}if (count > 0){p1 = pHead->next;while (p1){if (strcmp(p1->name, student_name) == 0){printf("\n姓名:%s,学号:%d,性别:%c  是否删除(y or n)?", p1->name, p1->one.id, p1->one.sex);c = _getch();if (c == 'y' || c == 'Y'){if (p1->next == NULL)//如果所删除的链表的下一段链表为空,则将当前的链表里的指针成(即next)赋值为空{pHead->next = NULL;break;}else//如果所删除的链表后边还有数据,则将当前链表的前一个结构体与它的后一个相连{pHead->next = p1->next;free(p1);p1 = pHead->next;}printf("成功!");}else//如果与所查找的人重名,则在选择不删除后继续往后查找//如果所查找的学生名字与当前的链表所存放的信息不一致,则将指针移到链表的下一个成员,再对比{pHead = pHead->next;p1 = pHead->next;}}else//如果与所查找的学生姓名不一致,则移动指针到链表下一位成员,继续查找{pHead = pHead->next;p1 = pHead->next;}}}}else{if (bum == 3){return;}else{delStudentInfo(pHead);}}}if (count == 0){printf("\n\t\t\t没有该学生信息!");}else{saveList(p2);}printf("\n按任意键返回主菜单");_getch();//防止函数运行完直接退出
}
/*================================================
== 函数名:void alterStudentInfo(Student *pHead)
== 功  能:修改学生信息
== 参  数:链表头指针
== 返回值:无
=================================================*/
void alterStudentInfo(Student* pHead)
{int bum, count = 0, j = 0;int num;char student_name[20];Student* p1 = pHead->next;system("title 学生成绩管理系统-修改");bum = scanMenu();if (bum == 1){printf("\n\t\t\t请输入要修改学生的学号:");scanf("%d", &num);while (p1){j++;if (p1->one.id == 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);
}
/*================================================
== 函数名:void findStudentInfo(Student *pHead)
== 功  能:数据查找,查找所需学生信息
== 参  数:链表头指针
== 返回值:无
=================================================*/
void findStudentInfo(Student* pHead)
{int bum, count = 0;int num;char student_name[20];pHead = pHead->next;system("title 学生成绩管理系统-查找");bum = scanMenu();if (bum == 1){printf("请输入学生的学号:");scanf("%d", &num);while (pHead){if (pHead->one.id == num){if (count == 0){printf("\n\t\t\t已经查到!\n");printf("\n\  ┏━━━━━━┳━━━━━━━━┳━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━┓");printf("\n  ┃ 学号 ┃ 姓 名  ┃性别┃高  数┃语  文┃ 英  语 ┃平均分┃总  分┃名次┃\n");count = 1;}printf("  ┣━━━━━━╋━━━━━━━━╋━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━┫\n");printf("  ┃ %-5d┃ %-6s ┃  %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", pHead->one.id,pHead->name, pHead->one.sex, pHead->one.gaoshu, pHead->one.yuwen,pHead->one.yingyu, 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");}}else{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\  ┏━━━━━━┳━━━━━━━━┳━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━┓");printf("\n  ┃ 学号 ┃ 姓 名  ┃性别┃高  数┃语  文┃ 英  语 ┃平均分┃总  分┃名次┃\n");count = 1;}printf("  ┣━━━━━━╋━━━━━━━━╋━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━┫\n");printf("  ┃ %-5d┃ %-6s ┃  %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", pHead->one.id,pHead->name, pHead->one.sex, pHead->one.gaoshu, pHead->one.yuwen,pHead->one.yingyu, pHead->one.aver_score, pHead->one.sum_score, pHead->rank);}pHead = pHead->next;}if (count == 0){printf("\n\t\t\t没有该学生记录!");}else{printf("  ┗━━━━━━┻━━━━━━━━┻━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━┛\n");}}else{if (bum == 3){return;}else{findStudentInfo(pHead);}}}_getch();
}
/*================================================
== 函数名:int statisMenu()
== 功  能:统计功能的菜单
== 参  数:无
== 返回值:方式对应整型数
=================================================*/
int statisMenu()
{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 statisStudentInfo(Student *pHead)
== 功  能:统计学生信息后并查看
== 参  数:链表头指针
== 返回值:无
=================================================*/void statisStudentInfo(Student* pHead)
{double aver_score[5] = { 0,0,0,0,0 };Student* p1 = pHead->next;int count = 0;int bad = 0, bum;system("title 学生成绩管理系统-统计");bum = statisMenu();if (bum == 1){while (p1){aver_score[0] = aver_score[0] + p1->one.gaoshu;aver_score[1] = aver_score[1] + p1->one.yuwen;aver_score[4] = aver_score[4] + p1->one.yingyu;p1 = p1->next;count++;//统计学生总数}aver_score[0] = aver_score[0] / count;//数组arver_score[0]存放高数平均分aver_score[1] = aver_score[1] / count;//数组arver_score[1]存放语文平均分aver_score[4] = aver_score[4] / count;//数组arver_score[4]存放英语平均分p1 = pHead->next;printf("\n\n  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");printf("  ┃\t高数的平均分为:%.1f,没有达到达到平均分的学生有        ┃\n", aver_score[0]);printf("  ┣━━━━━━┳━━━━━━━━┳━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━┫\n");printf("  ┃ 学号 ┃ 姓 名  ┃性别┃高  数┃语  文┃  英 语 ┃平均分┃总  分┃名次┃\n");printf("  ┣━━━━━━╋━━━━━━━━╋━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━┫\n");while (p1){if (p1->one.gaoshu < aver_score[0]){if (bad == 0){printf("  ┃ %-5d┃ %-6s ┃  %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", p1->one.id,p1->name, p1->one.sex, p1->one.gaoshu, p1->one.yuwen,p1->one.yingyu, p1->one.aver_score, p1->one.sum_score, p1->rank);}else{printf("  ┣━━━━━━╋━━━━━━━━╋━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━┫\n");printf("  ┃ %-5d┃ %-6s ┃  %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", p1->one.id,p1->name, p1->one.sex, p1->one.gaoshu, p1->one.yuwen,p1->one.yingyu, p1->one.aver_score, p1->one.sum_score, p1->rank);}bad = 1;}p1 = p1->next;}bad = 0;p1 = pHead->next;printf("  ┣━━━━━━┻━━━━━━━━┻━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━┫\n");printf("  ┃\t语文的平均分为:%.1f,没有达到达到平均分的学生有        ┃\n", aver_score[1]);printf("  ┣━━━━━━┳━━━━━━━━┳━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━┫\n");printf("  ┃ 学号 ┃ 姓 名  ┃性别┃高  数┃语  文┃  英 语 ┃平均分┃总  分┃名次┃\n");printf("  ┣━━━━━━╋━━━━━━━━╋━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━┫\n");while (p1){if (p1->one.yuwen < aver_score[1]){if (bad == 0){printf("  ┃ %-5d┃ %-6s ┃  %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", p1->one.id,p1->name, p1->one.sex, p1->one.gaoshu, p1->one.yuwen,p1->one.yingyu, p1->one.aver_score, p1->one.sum_score, p1->rank);}else{printf("  ┣━━━━━━╋━━━━━━━━╋━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━┫\n");printf("  ┃ %-5d┃ %-6s ┃  %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", p1->one.id,p1->name, p1->one.sex, p1->one.gaoshu, p1->one.yuwen,p1->one.yingyu, p1->one.aver_score, p1->one.sum_score, p1->rank);}bad = 1;}p1 = p1->next;}bad = 0;p1 = pHead->next;printf("  ┣━━━━━━┻━━━━━━━━┻━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━┫\n");printf("  ┃\t英语的平均分为:%.1f,没有达到达到平均分的学生有         ┃\n", aver_score[4]);printf("  ┣━━━━━━┳━━━━━━━━┳━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━┫\n");printf("  ┃ 学号 ┃ 姓 名  ┃性别┃高  数┃语  文┃  英 语 ┃平均分┃总  分┃名次┃\n");printf("  ┣━━━━━━╋━━━━━━━━╋━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━┫\n");while (p1){if (p1->one.yingyu < aver_score[4]){if (bad == 0){printf("  ┃ %-5d┃ %-6s ┃  %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", p1->one.id,p1->name, p1->one.sex, p1->one.gaoshu, p1->one.yuwen,p1->one.yingyu, p1->one.aver_score, p1->one.sum_score, p1->rank);}else{printf("  ┣━━━━━━╋━━━━━━━━╋━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━┫\n");printf("  ┃ %-5d┃ %-6s ┃  %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", p1->one.id,p1->name, p1->one.sex, p1->one.gaoshu, p1->one.yuwen,p1->one.yingyu, p1->one.aver_score, p1->one.sum_score, p1->rank);}bad = 1;}p1 = p1->next;}printf("  ┗━━━━━━┻━━━━━━━━┻━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━┛\n");printf("\t\t\t\t\t\t该班一共%d个人!", count);}else{if (bum == 2){bad = 0;printf("\n\n  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n");printf("  ┃\t高数成绩大于90分或小于60的学生有                       ┃\n");printf("  ┣━━━━━━┳━━━━━━━━┳━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━┫\n");printf("  ┃ 学号 ┃ 姓 名  ┃性别┃高  数┃语  文┃  英 语 ┃平均分┃总  分┃名次┃\n");printf("  ┣━━━━━━╋━━━━━━━━╋━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━┫\n");p1 = pHead->next;while (p1){if (p1->one.gaoshu < 60 || p1->one.gaoshu >= 90){if (bad == 0){printf("  ┃ %-5d┃ %-6s ┃  %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", p1->one.id,p1->name, p1->one.sex, p1->one.gaoshu, p1->one.yuwen,p1->one.yingyu, p1->one.aver_score, p1->one.sum_score, p1->rank);}else{printf("  ┣━━━━━━╋━━━━━━━━╋━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━┫\n");printf("  ┃ %-5d┃ %-6s ┃  %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", p1->one.id,p1->name, p1->one.sex, p1->one.gaoshu, p1->one.yuwen,p1->one.yingyu, p1->one.aver_score, p1->one.sum_score, p1->rank);}bad = 1;}p1 = p1->next;}bad = 0;printf("  ┣━━━━━━┻━━━━━━━━┻━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━┫\n");printf("  ┃\t语文成绩大于90分或小于60的学生有                       ┃\n");printf("  ┣━━━━━━┳━━━━━━━━┳━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━┫\n");printf("  ┃ 学号 ┃ 姓 名  ┃性别┃高  数┃语  文┃  英 语 ┃平均分┃总  分┃名次┃\n");printf("  ┣━━━━━━╋━━━━━━━━╋━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━┫\n");p1 = pHead->next;while (p1){if (p1->one.yuwen < 60 || p1->one.yuwen >= 90){if (bad == 0){printf("  ┃ %-5d┃ %-6s ┃  %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", p1->one.id,p1->name, p1->one.sex, p1->one.gaoshu, p1->one.yuwen,p1->one.yingyu, p1->one.aver_score, p1->one.sum_score, p1->rank);}else{printf("  ┣━━━━━━╋━━━━━━━━╋━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━┫\n");printf("  ┃ %-5d┃ %-6s ┃  %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", p1->one.id,p1->name, p1->one.sex, p1->one.gaoshu, p1->one.yuwen,p1->one.yingyu, p1->one.aver_score, p1->one.sum_score, p1->rank);}bad = 1;}p1 = p1->next;}bad = 0;printf("  ┣━━━━━━┻━━━━━━━━┻━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━┫\n");printf("  ┃\t英语成绩大于90分或小于60的学生有                        ┃\n");printf("  ┣━━━━━━┳━━━━━━━━┳━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━┫\n");printf("  ┃ 学号 ┃ 姓 名  ┃性别┃高  数┃语  文┃  英 语 ┃平均分┃总  分┃名次┃\n");printf("  ┣━━━━━━╋━━━━━━━━╋━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━┫\n");p1 = pHead->next;while (p1){if (p1->one.yingyu < 60 || p1->one.yingyu >= 90){if (bad == 0){printf("  ┃ %-5d┃ %-6s ┃  %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", p1->one.id,p1->name, p1->one.sex, p1->one.gaoshu, p1->one.yuwen,p1->one.yingyu, p1->one.aver_score, p1->one.sum_score, p1->rank);}else{printf("  ┣━━━━━━╋━━━━━━━━╋━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━┫\n");printf("  ┃ %-5d┃ %-6s ┃  %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", p1->one.id,p1->name, p1->one.sex, p1->one.gaoshu, p1->one.yuwen,p1->one.yingyu, p1->one.aver_score, p1->one.sum_score, p1->rank);}bad = 1;}p1 = p1->next;}printf("  ┗━━━━━━┻━━━━━━━━┻━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━┛\n");}else{if (bum == 3){return;}else{statisStudentInfo(pHead);}}}_getch();
}
/*================================================
== 函数名:int sortMenu()
== 功  能:排序方式菜单显示和选择
== 参  数:无
== 返回值:排序方式对应整型数
=================================================*/
int sortMenu()
{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 sortList(Student *pHead)
== 功  能:数据排序,查看所有学生信息
== 参  数:链表头指针
== 返回值:无
=================================================*/
void sortList(Student* pHead)
{Student* p1, * p2;StudentDate dat;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.aver_score > p1->one.aver_score){dat = 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 = dat;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.id < p1->one.id){dat = 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 = dat;p1->rank = rank;strcpy(p1->name, stu_name);}}}}else{if (bum == 3){return;}else{sortList(pHead);}}}printList(pHead);
}
/*================================================
== 函数名:void printList(Student *pHead)
== 功  能:链表数据打印
== 参  数:链表头指针
== 返回值:无
=================================================*/
void printList(Student* pHead)
{int count = 0;pHead = pHead->next;system("CLS");printf("\n\  ┏━━━━━━┳━━━━━━━━┳━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━┳━━━━┓");printf("\n  ┃ 学号 ┃ 姓 名  ┃性别┃高  数┃语  文┃ 英  语  ┃平均分┃总  分┃名次┃\n");while (pHead){printf("  ┣━━━━━━╋━━━━━━━━╋━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━━━╋━━━━┫\n");printf("  ┃ %-5d┃ %-6s ┃  %c ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃%5.1f ┃ %-3d┃\n", pHead->one.id,pHead->name, pHead->one.sex, pHead->one.gaoshu, pHead->one.yuwen,pHead->one.yingyu, pHead->one.aver_score, pHead->one.sum_score, pHead->rank);pHead = pHead->next;count++;}printf("  ┗━━━━━━┻━━━━━━━━┻━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━━━┻━━━━┛\n");printf("\t\t\t该班一共%d个人!", count);_getch();
}
/*================================================
== 函数名:void correctWord()
== 功  能:修改密码
== 参  数:无
== 返回值:无
=================================================*/
void correctWord()
{char password[20];FILE* fp;int i = 0;char c;system("title 学生成绩统计系统-修改密码");//将标题栏命名为“学生成绩统计系统”system("CLS");printf("\n\n\n\n\t\t\t请输入新的密码:");while ((c = _getch()) != 13 && i < 20){if (c == '\b' && i > 0){putchar('\b');putchar(' ');putchar('\b');i--;}else{if (isprint(c)){putchar('*');password[i] = c;i++;}}}password[i] = '\0';printf("\n\t\t\t是否将密码修改为<%s>? Y or N:", password);c = _getch();if (c == 'Y' || c == 'y'){fp = fopen("password.dat", "wb");fwrite(password, 20, 1, fp);fclose(fp);printf("\n\t\t\t修改成功!\n");}else{return;}_getch();
}
/*================================================
== 函数名:void gotoxy(int x, int y)
== 功  能:光标移动到指定位置
== 参  数:int x:列坐标int y:行坐标
== 返回值:无
=================================================*/
void gotoxy(int x, int y)//x为列坐标,y为行坐标
{COORD pos = { x, y };HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleCursorPosition(hOut, pos);
}

C语言写学生成绩管理系统(超详细注解)相关推荐

  1. mysql c语言写学生成绩管理系统,学生成绩管理系统C++实现代码

    本文实例为大家分享了C++学生成绩管理系统的具体代码,供大家参考,具体内容如下 * (程序头部注释开始) * 程序的版权和版本声明部分 * Copyright (c) 2011, 烟台大学计算机学院学 ...

  2. 用C语言写学生成绩管理系统

    源代码: test.c文件 #define _CRT_SECURE_NO_WARNINGS 1#include"student.h"void menu() {printf(&quo ...

  3. 用c语言实现成绩统计的设计,c语言实现学生成绩管理系统.doc

    c语言实现学生成绩管理系统.doc 学号102128121武汉理工大学华夏学院课程设计报告书课程名称:数据结构题目:用C语言实现成绩统计程序的设计系名:信息工程系专业班级:软件工程1121姓名:指导教 ...

  4. C语言实现学生成绩管理系统(原码)

    C语言实现学生成绩管理系统(单链表实现)很详细容易理解 #define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdl ...

  5. c语言学生管理系统write to a text file,语言编程学生成绩管理系统.doc

    语言编程学生成绩管理系统 c语言编程-学生成绩管理系统 #include /*引用库函数*/ #include #include #include typedef struct /*定义结构体数组*/ ...

  6. c语言编写简单的成绩管理系统,用c语言编写学生成绩管理系统

    <用c语言编写学生成绩管理系统>由会员分享,可在线阅读,更多相关<用c语言编写学生成绩管理系统(9页珍藏版)>请在人人文库网上搜索. 1.include#include#inc ...

  7. c语言程序学生成绩系统论文,c语言程序设计-学生成绩管理系统论文.doc

    c语言程序设计-学生成绩管理系统论文 C语言程序设计课程设计报告 - PAGE 11 - 中南民族大学工商学院 电子信息与计算机技术系 项目名称: 学生成绩管理系统 学生姓名: 学 号: 班 级: 指 ...

  8. 影碟管理系统c语言小学期,大连东软小学期C语言项目学生成绩管理系统代码.docx...

    大连东软小学期C语言项目学生成绩管理系统代码 /*链表版学生成绩管理系统的main函数与链表构建模块的代码*/#include #include #include struct STUDENT{ ch ...

  9. C语言编写学生成绩管理系统

    文章链接:https://codemouse.online/archives/2020-06-04-16-07-48 需求 用C语言编写学生成绩管理系统,要求该系统可 对学生操作:添加和删除操作. 可 ...

  10. c语言成绩管理系统总结分析报告,c语言下学生成绩管理系统程序设计报告

    <c语言下学生成绩管理系统程序设计报告>由会员分享,可在线阅读,更多相关<c语言下学生成绩管理系统程序设计报告(17页珍藏版)>请在人人文库网上搜索. 1.信息技术学院本科课程 ...

最新文章

  1. Android Studio 受不了了
  2. SSH Secure Shell显示GCC编译错误信息乱码解决方法
  3. C语言实例——判断是否为闰年
  4. java 注释添加引用_java – 如何引用注释处理中的方法的实现?
  5. Single sign-on,什么是单点登陆?
  6. 【Python-3.3】遍历字典键值练习
  7. http的response遇到illegalstateexception解决办法
  8. 快读快写:读入输出优化
  9. jmeter线程说明_jmeter 线程组
  10. ffmpeg命令分析-ss
  11. vue插槽面试题_vue面试题总结
  12. go语言 调用接口的方法
  13. float及float浮动坍塌问题
  14. python%是什么意思_%在Python中是什么意思?
  15. 阅读小结:The Unreasonable Effectiveness of Noisy Data for Fine-Grained Recognition
  16. 代码审计--17--修复方案汇总(上)
  17. linux wifi6,WIFI6 基本知识(一)
  18. Android最牛的开源整理
  19. 2009世界500强:《财富》全球五百家公司排名
  20. 假设银行一年整存零取的月息为1.875%(年息为12*1.875%,年息按复利计算),现在某人手头有一笔钱,他打算在今后5年中,每年年底取出1000元作为孩子来年的教育金,到第5年孩子毕业时刚好取完这

热门文章

  1. 中文停用词表(1893个)
  2. 【零基础 快速学Java】韩顺平 笔记整理(到p170 跑路了)
  3. Android自定义视频播放器
  4. c语言遗传算法百度云,遗传算法c语言程序.doc
  5. Win10鼠标宏怎么设置?电脑设置鼠标宏的方法
  6. 精通css和css权威指南_CSS中的笔触文字:权威指南
  7. 【独立小程序商城】THINKPHP带后台管理+MYSQL数据库微信小程序商城系统源码
  8. Lidar Studio点云处理与分析软件V1.1
  9. 2021年压力焊工作业考试题库
  10. mysql执行SQL脚本