




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、/ mxnnew.cpp : 定义控制台应用程序的入口点。#include stdafx.h#include #include /清屏#include /显示目录#include#includetypedef struct student unsigned long no; /学生学号 char name20; /学生姓名 float math; /数学成绩 float physics; /物理成绩 float English; /英语成绩 float computer; /计算机成绩 float sort; /成绩排名 float ave; /平均分 float sum; /总分 struc
2、t student *next;stu; stu *head;/*函数定义*/void initiate(stu *head1);/初始化void input(); /输入数据函数void display(); /显示数据函数void display1(); /显示单科数据函数void sort(); /排序数据函数void sort1(); /数学排序函数void sort2(); /物理排序函数void sort3(); /英语排序函数void sort4(); /计算机排序函数void modify(); /修改数据函数void del(); /删除数据函数void average();
3、 /平均值函数void find(); /查找数据函数void save(); /保存数据函数void read(); /读出数据函数void del_file(); /删除文件函数*/void main() /主函数 initiate(&head); int a; char ch; do printf(nnnntt); start: printf(nnnntt 欢迎进入中国地质大学(武汉)学生成绩管理系统n); printf(nnnntt按任意键继续next=NULL;void input() /录入数据函数char ch;stu *p,*q;p=head;printf(n是否新录入学生成绩
4、信息?(Y/N)); doq=(stu *)malloc(sizeof(stu); printf(tttt1.录入学生成绩信息n输入第个学生的信息n); printf(n请输入学生学号: t); scanf_s(%u,&q-no); fflush(stdin); printf(n请输入学生姓名: t); fflush(stdin); gets_s(q-name); printf(n请输入学生数学成绩: t); fflush(stdin); scanf_s(%f,&q-math); printf(n请输入学生物理成绩: t); scanf_s(%f,&q-physics); printf(n请输
5、入学生英语成绩: t); fflush(stdin); scanf_s(%f,&q-English); printf(n请输入学生计算机成绩: t); fflush(stdin); scanf_s(%f,&q-computer); q-next=p-next; p-next=q; printf(nn); printf(是否继续输入?(Y/N); fflush(stdin); ch=_getch(); system(cls); while(ch!=n&ch!=N); system(cls); /*输出信息功能模块*/void display() /显示数据函数 char a; stu *p; p
6、=head-next; average(); do printf(ttt已录入学生信息列表n); printf(t学号tt姓名t数学成绩t物理成绩t英语成绩t计算机成绩t平均值n); while(p!=NULL) printf(t%ut%st%.2ft%.2ft%.2ft%.2ft%.2fn,p-no,p-name,p-math,p-physics,p-English,p-computer,p-ave); p=p-next; printf(tt按任意键返回主菜单.); fflush(stdin); a=_getch(); while(!a); system(cls); void display
7、1() /显示数据函数stu *p; char a; do printf(ttt班级学生数学成绩排序n); printf(t学号tt姓名t数学成绩n); sort1(); p=head-next; while(p!=NULL) printf(t%ut%st%.2ftn,p-no,p-name,p-math); printf(ttt班级学生物理成绩排序n); printf(t学号tt姓名t物理成绩n); sort2(); p=head-next; while(p!=NULL) printf(t%ut%st%.2ftn,p-no,p-name,p-physics); printf(ttt班级学生英
8、语成绩排序n); printf(t学号tt姓名t英语成绩n); sort3(); p=head-next; while(p!=NULL) printf(t%ut%st%.2ftn,p-no,p-name,p-English); printf(ttt班级学生计算机成绩排序n); printf(t学号tt姓名t计算机成绩n); sort4(); p=head-next; while(p!=NULL) printf(t%ut%st%.2ftn,p-no,p-name,p-computer); printf(tt按任意键返回主菜单.); fflush(stdin); a=_getch(); while
9、(!a); system(cls); /单链表就地排序void sort()stu *curr,*pre,*p,*q; average();p=head-next;head-next=NULL;while(p!=NULL)curr=head-next;pre=head;while(curr!=NULL&curr-ave=p-ave)pre=curr;curr=curr-next;q=p;p=p-next;q-next=pre-next;pre-next=q; printf(排序已完成n); system(pause); system(cls); void sort1()stu *curr,*p
10、re,*p,*q; average();p=head-next;head-next=NULL;while(p!=NULL)curr=head-next;pre=head;while(curr!=NULL&curr-math=p-math)pre=curr;curr=curr-next;q=p;p=p-next;q-next=pre-next;pre-next=q;void sort2()stu *curr,*pre,*p,*q; average();p=head-next;head-next=NULL;while(p!=NULL)curr=head-next;pre=head;while(cu
11、rr!=NULL&curr-physics=p-physics)pre=curr;curr=curr-next;q=p;p=p-next;q-next=pre-next;pre-next=q;void sort3()stu *curr,*pre,*p,*q; average();p=head-next;head-next=NULL;while(p!=NULL)curr=head-next;pre=head;while(curr!=NULL&curr-English=p-English)pre=curr;curr=curr-next;q=p;p=p-next;q-next=pre-next;pr
12、e-next=q;void sort4()stu *curr,*pre,*p,*q; average();p=head-next;head-next=NULL;while(p!=NULL)curr=head-next;pre=head;while(curr!=NULL&curr-computer=p-computer)pre=curr;curr=curr-next;q=p;p=p-next;q-next=pre-next;pre-next=q;/*求平均数*/ void average()/求平均数函数 stu *p; p=head-next; while(p!=NULL) p-sum=p-m
13、ath+p-physics+p-English+p-computer; p-ave=p-sum/4; p=p-next; /*修改信息功能模块*/void modify() /修改数据函数 stu *p; p=head-next; char str20; printf(输入要修改的学生姓名:); fflush(stdin); gets_s(str); while(p!=NULL) if(!strcmp(p-name,str) system(cls); printf(ntt输入新插入学生信息n); printf(n输入学生学号:); fflush(stdin); scanf_s(%u,&p-no
14、); printf(n输入学生数学成绩:); fflush(stdin); scanf_s(%f,&p-math); printf(n输入学生物理成绩:); fflush(stdin); scanf_s(%f,&p-physics); printf(n输入学生英语成绩:); fflush(stdin); scanf_s(%f,&p-English); printf(n输入学生计算机成绩:); fflush(stdin); scanf_s(%f,&p-computer); printf(nn); sort(); break; p=p-next; system(cls); /*删除信息功能模块*/
15、void del() /删除数据函数stu *p,*q;p=head-next;q=head;unsigned long inum; printf(请输入要删除学生的学号:); fflush(stdin); scanf_s(%u,&inum); while(p!=NULL) if(p-no=inum) q-next=p-next; delete(p); sort(); break; elseq=p;p=p-next; system(cls); /*查找信息功能模块*/ void find() /查询函数 stu *p;p=head-next; char str20,as; do printf(
16、请输入要查询的学生姓名:); fflush(stdin); gets_s(str); while(p!=NULL) if(!strcmp(p-name,str) printf(t学号tt姓名t数学成绩t物理成绩t英语成绩t计算机成绩t平均值n); printf(t%ut%st%.2ft%.2ft%.2ft%.2ft%.2fn,p-no,p-name,p-math,p-physics,p-English,p-computer,p-ave); break; p=p-next; printf(tt按任意键返回主菜单.); fflush(stdin); as=_getch(); while(!as);
17、 system(cls); /*读入文件信息功能模块*/void read() /从文件中读入函数 stu *p,*q;p=head; FILE *fp; char filepath20; printf(输入要读入的文件路径:); fflush(stdin); gets_s(filepath); if(fp=fopen(filepath,r)=NULL) printf(找不到%s文件!n,filepath); system(pause); exit(0); clearerr(fp); while(feof(fp)=0) q=(stu *)malloc(sizeof(stu); /fscanf(
18、fp,%u%s%f%f%f%f%f%f,&q-no,q-name,&q-math,&q-physics,&q-English,&q-computer,&q-ave);fscanf(fp,%u,&q-no);fscanf(fp,%s,q-name);fscanf(fp,%f,&q-math);fscanf(fp,%f,&q-physics);fscanf(fp,%f,&q-English);fscanf(fp,%f,&q-computer);fscanf(fp,%f,&q-ave); q-next=head-next; head-next=q; p=head-next; head-next=p-next; fclose(fp); printf(保存的在文件%s中的所有信息已经读入!n,filepath); system(pause); /按任意键继续 system(cls); /*删除文件信息功能模块*/void del_file() /删除文件信息函数 FILE *fp; char filepath20; printf(输入要删除的文件路径:); fflush(stdin); gets_s(
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 企业合同范本制作
- 口才教室出租合同范本
- 企业采购合作合同范例
- 以物抵债合同范本
- 冷冻品购销合同范例
- 合唱排练协议合同范本
- 周口市安置房买卖合同范例
- 品牌店 转让 合同范本
- 厂房买卖合同范本模板
- 厨师人工合同范本
- 肿瘤心脏病学培训课件
- 开展健康生活方式、营养和慢性病预防知识教育和宣传活动
- 新编英语语法教程第六版课后答案全
- 2人退伍老兵表演军人小品《照相》台词
- 性传播疾病-课件
- 最新《桥梁工程》梁式桥和板式桥设计课件
- 无人机学习文件-飞行手册
- 典范英语教材-1a-课件
- 2023年扬州市职业大学单招职业适应性测试笔试题库及答案解析
- 供销联社审计:问题发现与整改情况报告
- 昆医大康复治疗技术课件09运动想象疗法
评论
0/150
提交评论