




已阅读5页,还剩18页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
让结局不留遗憾,让过程更加完美。#include#include#includestruct studentschar Num10; /*字符型学生学号*/char Name20; /*字符型学生姓名*/char Sex3; /*字符型学生性别*/double English; /*双精度实型英语成绩*/double Java; /*双精度实型Java成绩*/double Sjjg; /*双精度实数据结构*/double Szdl; /*双精度实型数字电路*/double Jsj; /*计算机组成原理*/struct students *next; /*用与构建连表指向下一结点*/;FILE *fp; /*定义全局变量fp*/void Revisemenu();/*修改菜单*/void Sortmenu();/*排序菜单*/void menu();/*主菜单*/void secret();/*安全验证*/struct students * Input();/*新建学生信息*/void fprint(struct students *head);/*将信息导入文件可追加*/void fprint_(struct students *head);/*将信息导入文件并覆盖*/void Browse(struct students *head);/*浏览全部学生信息*/struct students * create(struct students *headint *n);/*从tushu_list中读取数据构建链表*/void FindofNum(struct students *head);/*按学号查询学生信息*/void FindofNname(struct students *head);/*按姓名查询学生信息*/void SortEnglish(struct students * head);/*按英语成绩排序*/void SortJava(struct students * head);/*按Java成绩排序*/void SortSjjg(struct students * head);/*按数据结构成绩排序*/void SortSzdl(struct students * head);/*按数字逻辑电路成绩排序*/void SortJsj(struct students * head);/*按计算机组成原理成绩排序*/struct students * Delete(struct students * headchar m15);/*按学号删除学生成绩信息*/struct students * Revise();/*修改学生信息(按编号修改)*/*主菜单*/void menu()printf(nn);printf(*n);printf( 学生成绩管理系统 n);printf(-n);printf( 1-添加新同学 2-浏览学生信息 n);printf( 3-按学号查询 4-按姓名查询 n);printf( 5-按成绩排序 6-修改学生信息 n);printf( 7-删除学生信息 0-退出系统 n);printf(-n);printf(_n);/*排序菜单*/void Sortmenu()printf(nn);printf(*n);printf( 按成绩排序 n);printf( 1-大学英语 2-JAVA编程 n);printf( 3-数据结构 4-数字逻辑电路 n);printf( 5-计算机组成原理 0-返回上级菜单 n);printf(*n);/*修改菜单*/void Revisemenu()printf(nn); printf( 1-修改学生姓名 2-修改学生学号 n); printf( 3-修改学生性别 4-修改英语成绩 n); printf( 5-修改JAVA成绩 6-修改数据结构 n); printf( 7-修改数字电路 8-修改计算计 n);printf( 0-返回上级菜单 n); printf(nn);/*安全验证*/void secret()char a20;printf(*欢迎来到学生信息管理系统进入系统前请先进行密码验证-);printf( );dogets(a); /*输入密码*/system(cls); /*调用库函数清屏*/printf(对不起!您输入的密码有误请重新输入-);while(strcmp(a0605)!=0); /*单一密码0605*/system(cls);/*新建学生信息*/struct students * Input()struct students *p1*p2*head; /*建立辅助结点及头结点*/char Name;int n=0x;printf(n请按对应项输入学生信息以#结束:n);printf(姓名 学号 性别 英语 Java 数据结构 数字电路 计算机组成原理n);p1=(struct students *)malloc(sizeof(struct students);head=p2=p1;do /*使用do while语句输入学生信息*/scanf(%s&p1-Name);if(strcmp(p1-Name#)=0)break; /*判断结束符*/elsescanf(%s%s%lf%lf%lf%lf%lfp1-Nump1-Sex&p1-English&p1-Java&p1-Sjjg&p1-Szdl&p1-Jsj);Name=#;p1=(struct students *)malloc(sizeof(struct students);p2-next=p1;p2=p1;n+;while(1);p1-next=NULL;printf(学生信息输入结束!n);getchar(); printf(是否保存学生信息?(1.是/2.否):);scanf(%d&x);if(x=1)fprint(head); /*调用函数保存至文件*/elseprintf(n文件没有被保存!n);return head; /*返回头指针*/*将信息导入文件可追加*/void fprint(struct students *head)struct students *p1;if(fp=fopen(students_list.txta)=NULL)printf(File open error!n);exit(0);for(p1=head;p1-next!=NULL;p1=p1-next) /*遍历*/fprintf(fp%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp1-Namep1-Nump1-Sexp1-Englishp1-Javap1-Sjjgp1-Szdlp1-Jsj);/*将学生信息写入文件*/fclose(fp); /*关闭文件*/printf(n学生信息已成功保存到文件 students_list.txt 中!n);getchar();/*将信息导入文件并覆盖*/void fprint_(struct students *head)struct students *p1;if(fp=fopen(students_list.txtw)=NULL)printf(File open error!n);exit(0);for(p1=head;p1!=NULL;p1=p1-next) /*遍历*/fprintf(fp%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp1-Namep1-Nump1-Sexp1-Englishp1-Javap1-Sjjgp1-Szdlp1-Jsj);/*将学生信息写入文件*/fclose(fp); /*关闭文件*/;getchar();/*浏览全部学生信息*/void Browse(struct students *head) char Num10; /*字符型学生学号*/char Name20; /*字符型学生姓名*/char Sex3; /*字符型学生性别*/double English; /*双精度实型英语成绩*/double Java; /*双精度实型Java成绩*/double Sjjg; /*双精度实数据结构*/double Szdl; /*双精度实型数字电路*/double Jsj; /*计算机组成原理*/if(fp=fopen(students_list.txta+)=NULL)printf(File open error!n);exit(0);printf(-n);printf(姓名 学号 性别 英语 Java 数据结构 数字电路 计算机n);while(!feof(fp)/*读取并输出*/fscanf(fp%s%s%s%lf%lf%lf%lf%lfNameNumSex&English&Java&Sjjg&Szdl&Jsj);printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnNameNumSexEnglishJavaSjjgSzdlJsj);if(fclose(fp)printf(Can not close the file!n);exit(0);/*从tushu_list中读取数据构建链表*/struct students * create(struct students * headint *n)FILE *fp;struct students*p*p1*p2;if(fp=fopen(students_list.txta+)=NULL)printf(File open error!n);exit(0);while(!feof(fp)(*n)+; p=(struct students *)malloc(sizeof(struct students);fscanf(fp%s%s%s%lf%lf%lf%lf%lfp-Namep-Nump-Sex&p-English&p-Java&p-Sjjg&p-Szdl&p-Jsj);if(head=NULL)head=p;p1=p;elsep1-next=p;p2=p1;p1=p; p2-next=NULL;free(p);(*n)-;fclose(fp);return head;/*按姓名查询学生信息*/void FindofName(struct students *head)int i=0n=0; char b20; struct students *p;head=create(head&n);p=head;printf(n请输入要查询的学生姓名:);scanf(%sb);while(p!=NULL)if(strcmp(p-Nameb)=0) printf(姓名 学号 性别 英语 Java 数据结构 数字电路 计算机n);printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp-Namep-Nump-Sexp-Englishp-Javap-Sjjgp-Szdlp-Jsj);i+;p=p-next;if(i=0)printf(n对不起!没有找到名为%s的学生信息!nb);/*按学号查询学生信息*/void FindofNum(struct students *head)int i=0n;char b20;struct students *p;head=create(head&n);p=head;printf(n请输入要查询的学生学号:);scanf(%sb);while(p!=NULL)if(strcmp(p-Numb)=0)printf(姓名 学号 性别 英语 Java 数据结构 数字电路 计算机n);printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp-Namep-Nump-Sexp-Englishp-Javap-Sjjgp-Szdlp-Jsj);i+;p=p-next;if(i=0)printf(n对不起!没有找到学号为%s学生信息!nb);/*按英语成绩排序*/void SortEnglish(struct students * head)struct students *p*tail; /*定义中间变量*/int n;double English;p=(struct students *)malloc(sizeof(struct students);head=create(head&n);printf(姓名 学号 性别 英语 Java 数据结构 数字电路 计算机n);while(head-next!=NULL) /*利用选择法排序*/tail=NULL; p=head; English=p-English; /*将链表中第一个成绩赋给English*/ while(p!=NULL)if(p-English)English)/*比较*/English=p-English;tail=p; p=p-next;tail=NULL;p=head;while(p-next!=NULL)if(p-English=English)printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp-Namep-Nump-Sexp-Englishp-Javap-Sjjgp-Szdlp-Jsj);if(p=head)head=head-next;elsetail-next=p-next;tail=p;p=p-next;if(p-English=English) /*分数相同时无需比较*/printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp-Namep-Nump-Sexp-Englishp-Javap-Sjjgp-Szdlp-Jsj);tail-next=NULL;p=head; /*将链表赋给结构体指针*/printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp-Namep-Nump-Sexp-Englishp-Javap-Sjjgp-Szdlp-Jsj);/*浏览排序后的信息*/printf(按英语成绩排序后输出如上(注:此过程不保存至文件):n);return;/*按JAVA成绩排序*/void SortJava(struct students * head)struct students *p*tail; /*定义中间变量*/int n;double Java;p=(struct students *)malloc(sizeof(struct students);head=create(head&n);printf(姓名 学号 性别 英语 Java 数据结构 数字电路 计算机n);while(head-next!=NULL) /*利用选择法排序*/tail=NULL; p=head; Java=p-Java; /*将链表中第一个成绩赋给Java*/ while(p!=NULL)if(p-Java)Java)/*比较*/Java=p-Java;tail=p; p=p-next;tail=NULL;p=head;while(p-next!=NULL)if(p-Java=Java)printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp-Namep-Nump-Sexp-Englishp-Javap-Sjjgp-Szdlp-Jsj);if(p=head)head=head-next;elsetail-next=p-next;tail=p;p=p-next;if(p-Java=Java) /*成绩相同时无需比较*/printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp-Namep-Nump-Sexp-Englishp-Javap-Sjjgp-Szdlp-Jsj);tail-next=NULL;p=head; /*将链表赋给结构体指针*/printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp-Namep-Nump-Sexp-Englishp-Javap-Sjjgp-Szdlp-Jsj);/*浏览排序后的信息*/printf(按Java成绩排序后输出如上(注:此过程不保存至文件):n);return;/*按数据结构排序*/void SortSjjg(struct students * head)struct students *p*tail; /*定义中间变量*/int n;double Sjjg;p=(struct students *)malloc(sizeof(struct students);head=create(head&n);printf(姓名 学号 性别 英语 Java 数据结构 数字电路 计算机n);while(head-next!=NULL) /*利用选择法排序*/tail=NULL; p=head; Sjjg=p-Sjjg; /*将链表中第一个成绩赋给Sjjg*/ while(p!=NULL)if(p-Sjjg)Sjjg)/*比较*/Sjjg=p-Sjjg;tail=p; p=p-next;tail=NULL;p=head;while(p-next!=NULL)if(p-Sjjg=Sjjg)printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp-Namep-Nump-Sexp-Englishp-Javap-Sjjgp-Szdlp-Jsj);if(p=head)head=head-next;elsetail-next=p-next;tail=p;p=p-next;if(p-Sjjg=Sjjg) /*成绩相同时无需比较*/printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp-Namep-Nump-Sexp-Englishp-Javap-Sjjgp-Szdlp-Jsj);tail-next=NULL;p=head; /*将链表赋给结构体指针*/printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp-Namep-Nump-Sexp-Englishp-Javap-Sjjgp-Szdlp-Jsj);/*浏览排序后的信息*/printf(按数据结构成绩排序后输出如上(注:此过程不保存至文件):n);return;/*按数字电路排序*/void SortSzdl(struct students * head)struct students *p*tail; /*定义中间变量*/int n;double Szdl;p=(struct students *)malloc(sizeof(struct students);head=create(head&n);printf(姓名 学号 性别 英语 Java 数据结构 数字电路 计算机n);while(head-next!=NULL) /*利用选择法排序*/tail=NULL; p=head; Szdl=p-Szdl; /*将链表中第一个成绩赋给Szdl*/ while(p!=NULL)if(p-Szdl)Szdl)/*比较*/Szdl=p-Szdl;tail=p; p=p-next;tail=NULL;p=head;while(p-next!=NULL)if(p-Szdl=Szdl)printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp-Namep-Nump-Sexp-Englishp-Javap-Sjjgp-Szdlp-Jsj);if(p=head)head=head-next;elsetail-next=p-next;tail=p;p=p-next;if(p-Szdl=Szdl) /*成绩相同时无需比较*/printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp-Namep-Nump-Sexp-Englishp-Javap-Sjjgp-Szdlp-Jsj);tail-next=NULL;p=head; /*将链表赋给结构体指针*/printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp-Namep-Nump-Sexp-Englishp-Javap-Sjjgp-Szdlp-Jsj);/*浏览排序后的信息*/printf(按数字电路成绩排序后输出如上(注:此过程不保存至文件):n);return;/*按计算机组成原理排序*/void SortJsj(struct students * head)struct students *p*tail; /*定义中间变量*/int n;double Jsj;p=(struct students *)malloc(sizeof(struct students);head=create(head&n);printf(姓名 学号 性别 英语 Java 数据结构 数字电路 计算机n);while(head-next!=NULL) /*利用选择法排序*/tail=NULL; p=head; Jsj=p-Jsj; /*将链表中第一个成绩赋给Jsj*/ while(p!=NULL)if(p-Jsj)Jsj)/*比较*/Jsj=p-Jsj;tail=p; p=p-next;tail=NULL;p=head;while(p-next!=NULL)if(p-Jsj=Jsj)printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp-Namep-Nump-Sexp-Englishp-Javap-Sjjgp-Szdlp-Jsj);if(p=head)head=head-next;elsetail-next=p-next;tail=p;p=p-next;if(p-Jsj=Jsj) /*成绩相同时无需比较*/printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp-Namep-Nump-Sexp-Englishp-Javap-Sjjgp-Szdlp-Jsj);tail-next=NULL;p=head; /*将链表赋给结构体指针*/printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp-Namep-Nump-Sexp-Englishp-Javap-Sjjgp-Szdlp-Jsj);/*浏览排序后的信息*/printf(按计算机组成原理成绩排序后输出如上(注:此过程不保存至文件):n);return;/*按学号删除学生成绩信息*/struct students * Delete(struct students * headchar m15)struct students *ptr1*ptr2;int n; printf(n所有学生信息如下:n);Browse(head);printf(n请输入想要删除的学生学号:);scanf(%sm);head=create(head&n);if(head=NULL)printf(无学生信息!n);return head;if(strcmp(head-Numm)=0)&head!=NULL)ptr2=head;head=head-next;free(ptr2);if(strcmp(head-Numm)!=0)ptr1=head;ptr2=head-next;while(ptr2!=NULL)if(strcmp(ptr2-Numm)=0)ptr1-next=ptr2-next;free(ptr2);elseptr1=ptr2;ptr2=ptr1-next;fprint_(head);printf(n学号为 %s 学生信息已被删除并保存至文件!nm);return head;/*修改学生信息(按编号修改)*/struct students * Revise()int n=0t; char num10; char Num10; /*字符型学生学号*/char Name20; /*字符型学生姓名*/char Sex3; /*字符型学生性别*/double English; /*双精度实型英语成绩*/double Java; /*双精度实型Java成绩*/double Sjjg; /*双精度实数据结构*/double Szdl; /*双精度实型数字电路*/double Jsj; /*计算机组成原理*/ struct students *head=NULL; struct students *p; printf(n所有学生信息如下:n);Browse(head);head=create(head&n);printf(n输入需要修改的学生的学号:);scanf(%snum);p=head;while(head!=NULL)if(strcmp(p-Numnum)=0)system(cls);Revisemenu();printf(编号为%s的学生信息如下:nnum);printf(姓名 学号 性别 英语 Java 数据结构 数字电路 计算机n);printf(%st%st%st%.1lft%.1lft%.1lft%.1lft%.1lfnp-Namep-Nump-Sexp-Englishp-Javap-Sjjgp-Szdlp-Jsj);while(1)printf(请选择需要修改的信息:);scanf(%d&t);switch(t)case 1:printf(请输入新姓名:);scanf(%sName);strcpy(p-NameName);break;case 2:printf(请输入新学号:);scanf(%s&Num);strcpy(p-NumNum);break;case 3:printf(请输入新性别:);scanf(%sSex);strcpy(p-SexSex);break;case 4:printf(请输入新英语成绩:);scanf(%lf&English);p-English=English;break;case 5:
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026届甘肃省白银市靖远第一中学化学高二第一学期期中经典试题含解析
- 医疗废物转运知识培训课件
- 医疗器械基本知识培训课件
- 2025年冶金矿山阀门行业当前发展现状及增长策略研究报告
- 2025年射频器件行业当前发展趋势与投资机遇洞察报告
- 2025年文物保护技师资格认证考试试题及答案
- 2025年文化遗产保护技术员职业资格认证试卷及答案
- 2025年卫生健康管理师资格考试试题及答案
- 2025年网站运营高级技术人才认证考试试卷及答案
- 2025年网球俱乐部经理认证考试题及答案
- 脑梗死合并高血压护理查房
- 膝关节关节镜术后护理讲课件
- 爬架安全考试题及答案
- 2025年小学音乐教师资格考试试题及答案
- 我院科室护理病人隐私保护与信息安全
- 2025汽车销售合同标准经销商范本
- 暖通运维面试题库及答案
- 路面注浆打孔合同范本
- 新疆维吾尔自治区巴音郭楞蒙古自治州2024-2025学年八年级下学期期末模拟数学试题(无答案)
- DB32/T+5124.6-2025+临床护理技术规范+第6部分:成人危重症患者身体约束
- 资产收购方案(3篇)
评论
0/150
提交评论