已阅读5页,还剩30页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
#include #include #include #include #include #include #define YES 1#define NO 0typedef structint 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 studentchar name20;/学生姓名StudentDate one;/学生其他信息int rank;/成绩排名struct student *next;Student, *List;Student *startCheck(void);/开始检查Student *createListHead(void);/创建链表的头void menu(void);/主菜单void sortList(Student *pHead);/排序链表void readListWithFile(Student *pHead, char *file_name);/从文件中读取数据,并保存在链表中void sorttList(Student *pHead);/排序链表int userChioce(Student *pHead);/用户选择int sortMenu(void);/打印选择菜单void passwordCheck(void);/密码检测void correctWord(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 gotoxy(int x, int y);/改变光标位置函数void inputData(Student *pHead, Student *node);/输入信息,并检测是否合法int main(void)Student *pHead;HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);/得到窗口句柄SMALL_RECT rc = 0, 0, 94 - 1, 30 - 1 ; /Y位置,X位置,宽,高SetConsoleWindowInfo(hOut, true, &rc);/ 重置窗口位置和大小system(color 5B);/设置控制台颜色pHead = startCheck();/读取信息while (1)if (9 = userChioce(pHead) /按9时退出系统break;return 0;void menu(void)system(CLS);/清屏printf(nnnttttn);printf(tttt 学生成绩统计系统 n);printf(ttttn);printf(tttt 1 增加学生记录 n);printf(ttttn);printf(tttt 2 删除学生记录 n);printf(ttttn);printf(tttt 3 修改学生记录 n);printf(ttttn);printf(tttt 4 查找学生信息 n);printf(ttttn);printf(tttt 5 统计学生成绩 n);printf(ttttn);printf(tttt 6 查看学生成绩 n);printf(ttttn);printf(tttt 7 修改登陆密码 n);printf(ttttn);printf(tttt 8 关于 n);printf(ttttn);printf(tttt 9 退出系统 n);printf(ttttn);void gotoxy(int x, int y)/x为列坐标,y为行坐标COORD pos = x, y ;HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);SetConsoleCursorPosition(hOut, pos);Student *startCheck(void)Student *pHead;FILE *fp1;char password20 = 123456;int i;if (fp1 = fopen(password.dat, rb) = NULL)/若密码文件不存在,新建密码文件fp1 = fopen(password.dat, wb);fwrite(password, 20, 1, fp1);fclose(fp1);printf(密码初始化完成!(默认密码为:123456));passwordCheck();elsepasswordCheck();/读条system(CLS);system(title 学生成绩统计系统-载入中);/将标题栏命名为“学生成绩统计系统”printf(nnttt欢迎进入本系统!正在载入.);printf(nnnntttn);printf(ttt n);printf(tttn);gotoxy(26, 7);for ( i = 0; i next = NULL;return pHead;void readListWithFile(Student *pHead, char *file_name)FILE *fp;Student *p1, *p2;int count, rank = 0;StudentDate dat;char stu_name20;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%fn, &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.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 sortList(Student *pHead)Student *p1, *p2;StudentDate dat;char stu_name20;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);elseif (bum = 2)/按学号高低排序for (p1 = pHead-next; p1 != NULL; p1 = p1-next)for (p2 = p1-next; p2 != NULL; p2 = p2-next)if (p2-one.num one.num)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);elseif (bum = 3)return;elsesortList(pHead);printList(pHead);void printList(Student *pHead)int count = 0;pHead = pHead-next;system(CLS);printf(tttt计科6班成绩!);printf(nn );printf(n 学号 姓 名 性别语 文数 学英 语化 学物 理平均分总 分名次n);while (pHead) printf( n);printf( %-5d %-6s %c %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %-3dn, 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;count+;printf( n);printf(ttt该班一共%d个人!, count);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;case 7:correctWord();break;case 8:MessageBox(NULL, TEXT(特性:进入系统需输入密码,可以修改密码;展示学生信息时,以表格的方式呈现;输入学生信息时,不能输入已存在的学号;以链表、文件为基础;作者:HappyBeers), TEXT(关于), MB_OK);break; default:break;return bum;int sortMenu(void)int bum;system(CLS);printf(nnn);printf(ttn);printf(tt 以什么方式查询 ? n);printf(ttn);printf(tt 1 按成绩的高低 n);printf(ttn);printf(tt 2 按学号的升次 n);printf(ttn);printf(tt 3 返回主菜单 n);printf(ttn);printf(请按键选择:);bum = (int)(getch() - 0);system(CLS);return bum;void passwordCheck(void)char password20, inputword20;int i = 0, j = 0;char c = 0;FILE *fp = fopen(password.dat, rb);system(title 学生成绩统计系统-密码输入);/将标题栏命名为“学生成绩统计系统”fread(password, 20, 1, fp);for (i = 0; i 5; i+)j = 0;printf(nnntt你还有%d次机会输入正确密码: , 3-i);printf(nnnntttn);printf(ttt n);printf(tttn);gotoxy(26, 8);while (c = getch() != 13 & j 0)putchar(b);putchar( );putchar(b);j-;elseif (isprint(c)/isprint为检测C是否为可打印的函数 putchar(*);inputwordj = c;j+;inputwordj = 0;if (strcmp(inputword, password) = 0)return;elsesystem(CLS);printf(ttt密码输入错误);if (5 = i)system(CLS);printf(nnntt你已浪费所有机会!程序即将退出!);Sleep(2000);exit(0);fclose(fp);system(CLS);return;void correctWord(void)char password20;FILE *fp;int i = 0;char c;system(title 学生成绩统计系统-修改密码);/将标题栏命名为“学生成绩统计系统”system(CLS);printf(nnnnttt请输入新的密码:);while (c = getch() != 13 & i 0)putchar(b);putchar( );putchar(b);i-;elseif (isprint(c)/isprint为检测C是否为可打印的函数 putchar(*);passwordi = c;i+;passwordi = 0;printf(nttt是否将密码修改为? Y or N:, password);c = getch();if (c = Y | c = y)fp = fopen(password.dat, wb);fwrite(password, 20, 1, fp);fclose(fp);printf(nttt修改成功!n);elsereturn;getch();void addStudentInfo(Student *pHead)FILE *fp;Student *p1, *p2, *p3 = pHead;StudentDate dat;int judge = YES, rank = 0;char bum, stu_name20;system(title 学生成绩统计系统-添加);/将标题栏命名为“学生成绩统计系统”fp = fopen(stud.dat, 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 %.1fn, 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)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);int scanMenu(void)int bum;system(CLS);printf(nnn);printf(ttn);printf(tt 以什么方式查询 ? n);printf(ttn);printf(tt 1 按学生的学号 n);printf(ttn);printf(tt 2 按学生的姓名 n);printf(ttn);printf(tt 3 返回主菜单 n);printf(ttn);printf(请按键选择:);bum = (int)(getch() - 0);system(CLS);return bum;void findStudentInfo(Student *pHead)int bum, count = 0;int num;char student_name20;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(nttt已经查到!n);printf(nnnn );printf(n 学号 姓 名 性别语 文数 学英 语化 学物 理平均分总 分名次n);count = 1;printf( n);printf( %-5d %-6s %c %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %-3dn, 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(nttt没有该学生记录!n);elseprintf( n);elseif (bum = 2)printf(请输入学生姓名:);scanf(%s, student_name);while (pHead)if (strcmp(student_name, pHead-name) = 0)if (count = 0)printf(nttt已经查到!n);printf(nnnn );printf(n 学号 姓 名 性别语 文数 学英 语化 学物 理平均分总 分名次n);count = 1;printf( n);printf( %-5d %-6s %c %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %5.1f %-3dn, 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(nttt没有该学生记录!);elseprintf( n);elseif (bum = 3)return;elsefindStudentInfo(pHead);getch();void delStudentInfo(Student *pHead)Student *p1, *p2 = pHead;int bum;int num, count = 0;char student_name20, c;system(title 学生成绩统计系统-删除);/将标题栏命名为“学生成绩统计系统”bum = scanMenu();if (bum = 1)p1 = pHead-next;printf(nttt请输入要删除学生的学号:);scanf(%d, &num);while (p1)if (p1-one.num = num)count = 1;printf(nttt删除成功,删除的学生学号为:%d, num);if (p1-next = NULL)pHead-next = NULL;break;elsepHead-next = p1-next;free(p1);p1 = pHead-next;elsepHead = pHead-next;p1 = pHead-next;elseif (bum = 2)p1 = pHead-next;printf(nttt请输入要删除的学生姓名:);scanf(%s, student_name);/统计一共有多少个学生while (p1)if (strcmp(p1-name, student_name) = 0)count+;p1 = p1-next;if (count 0)printf(nnnttt一共有%d个人的信息 全部删除(Y) or 逐一删除(N)?, count);/选择全部删除,还是逐一删除c = getch();/全部删除if (c = y | c = Y)p1 = pHead-next;while (p1)if (strcmp(p1-name, student_name) = 0)printf(nttt删除成功,姓名为: %s, student_name);if (p1-next = NULL)pHead-next = NULL;break;elsepHead-next = p1-next;free(p1);p1 = pHead-next;elsepHead = pHead-next;p1 = pHead-next;else/逐一删除p1 = pHead-next;while (p1)if (strcmp(p1-name,student_name) = 0)printf(n姓名:%s,学号:%d,性别:%c 是否删除(y or n)?, p1-name, p1-one.num, p1-one.sex);c = getch();if (c = y| c = Y)if (p1-next = NULL)pHead-next = NULL;break;elsepHead-next = p1-next;free(p1);p1 = pHead-next;printf(成功!);elsepHead = pHead-next;p1 = pHead-next;elsepHead = pHead-next;p1 = pHead-next;elseif (bum = 3)return;elsedelStudentInfo(pHead);if (count = 0)printf(nttt没有该学生信息!);elsesaveList(p2);getch();void saveList(Student *pHead)FILE *fp;fp = fopen(stud.dat, w+);pHead = pHead-next;while (pHead)fprintf(fp, %d %s %c %.1f %.1f %.1f %.1f %.1fn, 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_name20;Student *p1 = pHead-next;system(title 学生成绩统计系统-修改);/将标题栏命名为“学生成绩统计系统”bum = scanMenu();if (bum = 1)printf(nttt请输入要修改学生的学号:);scanf(%d, &num);while (p1)j+;if (p1-one.
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2023年四川安和精密电子电器股份有限公司招聘考试真题
- 陕西省广播电视技术推广中心招聘真题
- 苹果专卖店活动促销
- 农村个人购房协议书格式范本
- 服装厂安全用电
- 盆底康复治疗案例分享
- 南泥湾镇污水处理站建设工程项目可行性实施报告
- ××房地产项目可行性研究报告
- 采购员工年终总结报告大全10篇
- 区域饮料酒承包合同范本
- 信息系统部署与运维-题库带答案
- 婚姻心理学解读包含内容
- DZ/T 0462.3-2023 矿产资源“三率”指标要求 第3部分:铁、锰、铬、钒、钛(正式版)
- 备战2024年高考英语考试易错点12 名词性从句(4大陷阱)(解析版)
- 公务员历史常识100题及一套完整答案
- 信息技术与高中英语教学融合的途径
- 花篮拉杆式悬挑脚手架.计算书及相关图纸
- 职业道德与法律说课稿市公开课一等奖省赛课微课金奖课件
- 《电力建设施工技术规范 第2部分:锅炉机组》DLT 5190.2
- 史学概论完整版本
- 供水管网抢修管理课件
评论
0/150
提交评论