版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、# include<stdio.h># include "stdlib.h"# include "string.h" #include <iostream.h>struct student *Read();void save(struct student *head);void sinput(struct student *p);struct student *input();void paixu_num(struct student *head);struct student *insert();struct student *
2、alter();struct student *del();void find_num(struct student *phead);void find_name(struct student *phead);void output();void min_student(struct student *phead);void max_student(struct student *phead);void ave_student(struct student *phead);void every_student(struct student *phead);void score_paixu(st
3、ruct student *head);void help();void tj_menu(struct student *head);void find_menu(struct student *head);void menu();struct student/ 定义学生信息结构数组,用于学生信息输入 char number13;char name13;char sex4;char adds15;char phone14;char qq14;float chinese,math,english,txhp,pinde,teacher;int zcmc,ksmc;double ave,zc;str
4、uct student *next;#define Len sizeof(struct student)int len; /链表长度int a=0,b=0,c=0,d=0,e=0;/用来存放成绩各阶的人数精选文库char stu10;struct student *Read() /读取数据文件保存到链表中, 返回指向此链表头指针struct student *head=NULL;struct student *p1, *p2;FILE *fp;cout<<" 请输入你要打开的文件(.dat)"<<endl;cin>>stu;if(fp=f
5、open(stu,"rb+")=NULL)cout<<" 打开文件出错!"<<endl;exit(0);while(!feof(fp) if( (p1=(struct student*)malloc(Len)=NULL )cout<<" 内存申请出错 "<<endl;fclose(fp);exit(0);if(fread(p1,Len,1,fp)!=1)free(p1);break;if(head=NULL)head=p2=p1;elsep2->next=p1;p2=p1;fclo
6、se(fp);return head;void save(struct student *head)/数据存盘FILE *fp;struct student *p;p=head;cout<<" 请输入你要存进去的文件(.dat)"<<endl;-2精选文库cin>>stu;if(fp = fopen(stu, "wb")=NULL)cout<<" 无法打开文件 !"<<endl;system("pause");menu();while(p)if(fwrit
7、e(p,Len,1,fp)!=1)cout<<" 写入数据出错 "<<endl;fclose(fp);return;elsep=p->next;cout<<" 数据存入成功 ! 请按任意键继续 !"<<endl;getchar();fclose(fp);/ 单次输入void sinput(struct student *p)cout<<" 请输入学号 :"<<endl;cin>>p->number;cout<<" 请输
8、入姓名 : "<<endl;cin>>p->name;cout<<" 请输入性别 : "<<endl;cin>>p->sex;cout<<" 请输入家庭住址: "<<endl;cin>>p->adds;cout<<" 请输入联系电话: "<<endl;cin>>p->phone;cout<<" 请输入 qq: "<<endl;c
9、in>>p->qq;cout<<" 请输入语文成绩:"<<endl;cin>>p->chinese;if(p->chinese>100|p->chinese<0)-3精选文库cout<<" 成绩输入不符合规定,请重新输入:"<<endl;cin>>p->chinese;cout<<" 请输入数学成绩:"<<endl;cin>>p->math;if(p->math&
10、gt;100|p->math<0)cout<<" 成绩输入不符合规定,请重新输入:"<<endl;cin>>p->math;cout<<" 请输入英语成绩:"<<endl;cin>>p->english;if(p->english>100|p->english<0)cout<<" 成绩输入不符合规定,请重新输入:"<<endl;cin>>p->english;cout<
11、<" 请输入同学互评分:"<<endl;cin>>p->txhp;if(p->txhp>100|p->txhp<0)cout<<" 成绩输入不符合规定,请重新输入:"<<endl;cin>>p->txhp;cout<<" 请输入品德成绩:"<<endl;cin>>p->pinde;if(p->pinde>100|p->pinde<0)cout<<"
12、 成绩输入不符合规定,请重新输入:"<<endl;cin>>p->pinde;cout<<" 请输入任课教师评分:"<<endl;cin>>p->teacher;if(p->teacher>100|p->teacher<0)cout<<" 成绩输入不符合规定,请重新输入:"<<endl;cin>>p->teacher;p->ave=(p->chinese+p->math+p->engl
13、ish)/3.0; p->zc=(p->ave*0.6+p->txhp*0.1+p->pinde*0.2+p->teacher*0.1);-4精选文库cout<<endl;cout<<" "<<endl;cout<<" 你刚输入的信息为:"<<endl;cout<<"tt学号 :"<<p->number<<endl;cout<<"tt姓名 :"<<p->n
14、ame<<endl;cout<<"tt性别 :"<<p->sex<<endl;cout<<"tt家庭住址 :"<<p->adds<<endl;cout<<"tt联系电话 :"<<p->phone<<endl;cout<<"ttQQ号 :"<<p->qq<<endl;cout<<"tt语文成绩: "<&
15、lt;p->chinese<<endl;cout<<"tt数学成绩 :"<<p->math<<endl;cout<<"tt英语成绩 :"<<p->english<<endl;cout<<"tt品德成绩 :"<<p->pinde<<endl;cout<<"tt教师评分 :"<<p->teacher<<endl;cout<<
16、" "<<endl;return;/ 学生成绩录入函数struct student *input()struct student *head=NULL,*p1,*p2;/输入 p1,p2 链表最后节点char ch='y'len=1;p2=p1=(struct student *)malloc(sizeof(struct student);cout<<" 请输入第 "<<len<<" 个学生的信息 :"<<endl;sinput(p1);cout<<
17、;endl;cout<<" 按 n 退出或按任意键继续"<<endl;cin>>ch;while(1)if(len=1)/作为头结点head=p1;elsep2->next=p1;p2=p1;if(ch='N'|ch='n')break;p1=(struct student *)malloc(sizeof(struct student);system("cls");len+;-5精选文库cout<<" 请输入第 "<<len<<
18、;" 个学生的信息 :"<<endl;sinput(p1);cout<<endl;cout<<" 按 n 退出或按任意键继续"<<endl;cin>>ch;p2->next=NULL;paixu_num(head);cout<<" 输入学生信息完成! 请按任意键返回主菜单!"<<endl;getchar();return head;/ 学号排序void paixu_num(struct student *head)struct student t
19、,*r,*p,*q;/t交换 p、q, r 头结点r=head;if(r=NULL)cout<<" 学生信息不存在, 请先输入学生信息!"<<endl;return;while(r)p=r;q=r->next;while(q)if(strcmp(q->number,p->number)<0) /q<pstrcpy(t.number,q->number);strcpy(,q->name);strcpy(t.sex,q->sex);strcpy(t.adds,q->adds);strcpy
20、(t.phone,q->phone);strcpy(t.qq,q->qq);t.chinese=q->chinese;t.math=q->math;t.english=q->english;t.txhp=q->txhp;t.pinde=q->pinde;-6精选文库t.teacher=q->teacher;strcpy(q->number,p->number);strcpy(q->name,p->name);strcpy(q->sex,p->sex);strcpy(q->adds,p->adds);
21、strcpy(q->phone,p->phone);strcpy(q->qq,p->qq);q->chinese=p->chinese;q->math=p->math;q->english=p->english;q->txhp=p->txhp;q->pinde=p->pinde;q->teacher=p->teacher;strcpy(p->number,t.number);strcpy(p->name,);strcpy(p->sex,t.sex);strcpy(p-&
22、gt;adds,t.adds);strcpy(p->phone,t.phone);strcpy(p->qq,t.qq);p->chinese=t.chinese;p->math=t.math;p->english=t.english;p->txhp=t.txhp;p->pinde=t.pinde;p->teacher=t.teacher;q=q->next;r=r->next;/ 插入函数struct student *insert()struct student *p,*p1,*head;head=Read();p1=head;p=
23、(struct student *)malloc(sizeof(struct student);char num14,ch;cout<<" 请输入你要插入的前一个学生的学号:"<<endl;cin>>num;-7精选文库while(p1)if(!strcmp(p1->number,num)sinput(p);p->next=p1->next;p1->next=p;len+;elsep1=p1->next;cout<<" 按 n 退出或按任意键继续"<<endl;ci
24、n>>ch;if(ch='N'|ch='n')break;cout<<" 学生信息插入成功!请按任意键返回!"<<endl;getchar();return head;/ 修改学生信息struct student *alter()char temp13;struct student *p,*head;head=Read();p=head;cout<<" 请输入要修改学生的学号:"cin>>temp;while(p)if(!strcmp(p->number,t
25、emp)sinput(p);p=p->next;cout<<endl;cout<<" 学生信息修改成功!请按任意键返回!"<<endl;cout<<endl;system("pause");return head;-8精选文库/ 删除学生信息struct student *del()char temp13;int m=0;struct student *p1,*p,*head;/p1删除head=Read();p1=p=head;cout<<" 请输入你要删除学生的学号:&quo
26、t;<<endl;cin>>temp;while(p)if(strcmp(p1->number,temp)=0)if(p1=head)/删除的头结点head=p1->next;elsep->next=p1->next;len-;m=1;cout<<" 学生信息删除成功!请按任意键返回主菜单."<<endl;getchar();return head;elsep=p->next;if(!m)cout<<" 查找不到这个信息!"<<endl;return h
27、ead;void find_num(struct student *head)/按学号查找struct student *p=head;char temp9;int m = 0;cout<<" 请输入要查找的学生的学号"<<endl;cin>>temp;while(p!=NULL)if(strcmp(p->number,temp) = 0)-9精选文库cout<<" 该学生的具体信息为:"<<endl;cout<<endl;cout<<" "&l
28、t;<endl; cout<<"tt 学号 :"<<p->number<<endl; cout<<"tt 姓名 :"<<p->name<<endl;cout<<"tt性别 :"<<p->sex<<endl;cout<<"tt家庭住址 :"<<p->adds<<endl;cout<<"tt联系电话 :"<&l
29、t;p->phone<<endl;cout<<"ttQQ号 :"<<p->qq<<endl;cout<<"tt语文成绩: "<<p->chinese<<endl;cout<<"tt数学成绩 "<<p->math<<endl;cout<<"tt英语成绩 "<<p->english<<endl;cout<<"tt平
30、均成绩 "<<p->ave<<endl;cout<<"tt品德成绩 "<<p->pinde<<endl;cout<<"tt老师评分 "<<p->teacher<<endl;cout<<"tt综合成绩 "<<p->zc<<endl;score_paixu(head);cout<<"tt考试名次 "<<p->ksmc<&
31、lt;endl;cout<<"tt综测名次 "<<p->zcmc<<endl;cout<<" "<<endl;cout<<endl; m=1;p= p->next;/继续向下寻找if(!m)cout<<" 查找不到这个学号的信息!"<<endl;cout<<" 按任意键返回主菜单"<<endl;getchar();return ;void find_name(struct studen
32、t *head)/按姓名查找struct student *p= head;char temp9;int m = 0;cout<<" 请输入要查找的学生的姓名"<<endl;cin>>temp;while(p)if(strcmp(p->name,temp) = 0)-10精选文库cout<<" 该学生的具体信息为:"<<endl;cout<<endl;cout<<" "<<endl; cout<<" 学号 :&q
33、uot;<<p->number<<endl;cout<<"tt姓名 :"<<p->name<<endl;cout<<"tt性别 :"<<p->sex<<endl;cout<<"tt家庭住址 :"<<p->adds<<endl;cout<<"tt联系电话 :"<<p->phone<<endl;cout<<&qu
34、ot;ttQQ号 :"<<p->qq<<endl;cout<<"tt语文成绩: "<<p->chinese<<endl;cout<<"tt数学成绩 "<<p->math<<endl;cout<<"tt英语成绩 "<<p->english<<endl;cout<<"tt平均成绩 "<<p->ave<<endl;c
35、out<<"tt品德成绩 "<<p->pinde<<endl;cout<<"tt老师评分 "<<p->teacher<<endl;cout<<"tt综合成绩 "<<p->zc<<endl;score_paixu(head);cout<<"tt考试名次 "<<p->ksmc<<endl;cout<<"tt综测名次 "&l
36、t;<p->zcmc<<endl;cout<<" "<<endl;cout<<endl; m=1;p=p->next;if(!m)cout<<" 查找不到这个学号的信息!"<<endl;cout<<" 按任意键返回主菜单"<<endl;getchar();return ;void output()struct student *p,*head;head=Read();p=head;int i=1;while(p)cout&
37、lt;<" "<<endl; cout<<"tt 学号 :"<<p->number<<endl;-11精选文库cout<<"tt姓名 :"<<p->name<<endl;cout<<"tt性别 :"<<p->sex<<endl;cout<<"tt家庭住址 :"<<p->adds<<endl;cout<<
38、;"tt联系电话 :"<<p->phone<<endl;cout<<"ttQQ号 :"<<p->qq<<endl;cout<<"tt语文成绩: "<<p->chinese<<endl;cout<<"tt数学成绩 :"<<p->math<<endl;cout<<"tt英语成绩 :"<<p->english<&
39、lt;endl;cout<<"tt品德成绩 :"<<p->pinde<<endl;cout<<"tt老师评分 :"<<p->teacher<<endl;cout<<"tt平均成绩 :"<<p->ave<<endl;cout<<"tt综合成绩 :"<<p->zc<<endl;score_paixu(head);cout<<"tt考
40、试名次 "<<p->ksmc<<endl;cout<<"tt综合测评名次 "<<p->zcmc<<endl;p=p->next;i+;cout<<" "<<endl; cout<<endl;cout<<" 请按任意键返回主菜单"<<endl;getchar();return ;void max_student(struct student *head)struct student *p=h
41、ead;float c2=0,m2=0,e2=0,s2=0,p2=0,stu2=0,t2=0;double a2=0,zc2=0;while(p)if(p->chinese>c2)c2=p->chinese;if(p->math>m2)m2=p->math;if(p->english>e2)e2=p->english;if(p->chinese+p->math+p->english)>s2)s2=(p->chinese+p->math+p->english);if(p->pinde>p2
42、)p2=p->pinde;if(p->txhp>stu2)-12精选文库stu2=p->txhp;if(p->teacher>t2)t2=p->teacher;if(p->ave>a2)a2=p->ave;if(p->zc>zc2)zc2=p->zc;p=p->next;cout<<" "<<endl; cout<<"tt 语文最高分 :"<<c2<<endl;cout<<"tt数学最高分
43、:"<<m2<<endl;cout<<"tt英语最高分 :"<<e2<<endl;cout<<"tt总成绩最高分 :"<<s2<<endl;cout<<"tt品德最高分: "<<p2<<endl;cout<<"tt同学互评分最高:"<<stu2<<endl;cout<<"tt教师评分最高: "<<
44、t2<<endl;cout<<"tt平均分最高: "<<a2<<endl;cout<<"tt综测最高分: "<<zc2<<endl;cout<<" "<<endl; cout<<endl;cout<<" 请按任意键返回 ."<<endl;getchar();return;void min_student(struct student *head)struct student
45、 *p=head;float c1=100,m1=100,e1=100,s1=100,p1=100,stu1=100,t1=100; double a1=100,zc1=100;while(p) if(p->chinese<c1)c1=p->chinese;if(p->math<m1)m1=p->math;if(p->english<e1)e1=p->english;if(p->chinese+p->math+p->english)<s1)s1=(p->chinese+p->math+p->engl
46、ish);if(p->pinde<p1)p1=p->pinde;if(p->txhp<stu1)-13精选文库stu1=p->txhp;if(p->teacher<t1)t1=p->teacher;if(p->ave<a1)a1=p->ave;if(p->zc<zc1)zc1=p->zc;p=p->next;cout<<" "<<endl; cout<<"tt 语文最低分 :"<<c1<<endl;c
47、out<<"tt数学最低分 :"<<m1<<endl;cout<<"tt英语最低分 :"<<e1<<endl;cout<<"tt总成绩最低分 :"<<s1<<endl;cout<<"tt品德最低分: "<<p1<<endl;cout<<"tt同学互评分最低分:"<<stu1<<endl;cout<<&quo
48、t;tt教师评分最低分:"<<t1<<endl;cout<<"tt平均分最低分: "<<a1<<endl;cout<<"tt综测最低分: "<<zc1<<endl;cout<<" "<<endl; cout<<endl;cout<<" 请按任意键返回 ."<<endl;getchar();return;void ave_student(struct s
49、tudent *head)struct student *p=head;float c_sum=0,m_sum=0,e_sum=0,p_sum=0,stu_sum=0,t_sum=0;float c_ave=0,m_ave=0,e_ave=0,all_ave=0,p_ave=0,stu_ave=0,t_ave=0; double zc_sum=0,zc_ave=0;while(p)c_sum+=p->chinese;m_sum+=p->math;e_sum+=p->english;p_sum+=p->pinde;stu_sum+=p->txhp;t_sum+=p-
50、>teacher;zc_sum+=p->zc;p=p->next;-14精选文库c_ave=c_sum/len;m_ave=m_sum/len;e_ave=e_sum/len;all_ave=(c_ave+m_ave+e_ave)/3;p_ave=p_sum/len;stu_ave=stu_sum/len;t_ave=t_sum/len;zc_ave=zc_sum/len;cout<<"tt "<<endl; cout<<"tt 语文平均分为 :"<<c_ave<<endl;
51、cout<<"tt 数学平均分为 :"<<m_ave<<endl;cout<<"tt英语平均分为 :"<<e_ave<<endl;cout<<"tt总成绩平均为 :"<<all_ave<<endl;cout<<"tt品德平均分为 :"<<p_ave<<endl;cout<<"tt同学互评平均分为:"<<stu_ave<<
52、;endl;cout<<"tt教师评分平均分为:"<<t_ave<<endl;cout<<"tt综测平均分为 :"<<zc_ave<<endl;cout<<"tt "<<endl; cout<<endl;cout<<" 请按任意键返回 ."<<endl;getchar();return;void every_student(struct student *head)struct stu
53、dent *p=head;while(p)switch(int)p->ave/10)case 10:case 9:a+;break;case 8:b+;break;case 7:c+;break;case 6:d+;break;default:e+;p=p->next;cout<<" "<<endl; cout<<" 平均成绩在 90 分以上的有: "<<a<<endl;cout<<" 平均成绩在80 分以上的有: "<<b<<
54、endl;cout<<" 平均成绩在70 分以上的有: "<<c<<endl;-15精选文库cout<<" 平均成绩在60 分以上的有: "<<d<<endl;cout<<" 平均成绩在60 分以下的有: "<<e<<endl;while(p)switch(int)p->chinese/10)case 10:case 9:a+;break;case 8:b+;break;case 7:c+;break;case 6:d+;
55、break;default:e+;p=p->next;cout<<" "<<endl;cout<<" 语文成绩在90 分以上的有: "<<a<<endl;cout<<" 语文成绩在80 分以上的有: "<<b<<endl;cout<<" 语文成绩在70 分以上的有: "<<c<<endl;cout<<" 语文成绩在60 分以上的有: "<&l
56、t;d<<endl;cout<<" 语文成绩在60 分以下的有: "<<e<<endl;while(p)switch(int)p->math/10)case 10:case 9:a+;break;case 8:b+;break;case 7:c+;break;case 6:d+;break;default:e+;p=p->next;cout<<" "<<endl;cout<<" 数学成绩在90 分以上的有: "<<a<&l
57、t;endl;cout<<" 数学成绩在80 分以上的有: "<<b<<endl;cout<<" 数学成绩在70 分以上的有: "<<c<<endl;cout<<" 数学成绩在60 分以上的有: "<<d<<endl;cout<<" 数学成绩在60 分以下的有: "<<e<<endl;while(p)switch(int)p->english/10)-16精选文库ca
58、se 10:case 9:a+;break;case 8:b+;break;case 7:c+;break;case 6:d+;break;default:e+;p=p->next;cout<<" "<<endl;cout<<" 英语成绩在90 分以上的有: "<<a<<endl;cout<<" 英语成绩在80 分以上的有: "<<b<<endl;cout<<" 英语成绩在70 分以上的有: "<
59、<c<<endl;cout<<" 英语成绩在60 分以上的有: "<<d<<endl;cout<<" 英语成绩在60 分以下的有: "<<e<<endl;while(p)switch(int)p->pinde/10)case 10:case 9:a+;break;case 8:b+;break;case 7:c+;break;case 6:d+;break;default:e+;p=p->next;cout<<" "<
60、;<endl; cout<<" 品德成绩在 90 分以上的有: "<<a<<endl;cout<<" 品德成绩在80 分以上的有: "<<b<<endl;cout<<" 品德成绩在70 分以上的有: "<<c<<endl;cout<<" 品德成绩在60 分以上的有: "<<d<<endl;cout<<" 品德成绩在60 分以下的有: "
61、<<e<<endl;while(p)switch(int)p->txhp/10)case 10:case 9:a+;break;case 8:b+;break;case 7:c+;break;case 6:d+;break;-17精选文库default:e+;p=p->next;cout<<" "<<endl;cout<<" 同学互评在90 分以上的有: "<<a<<endl;cout<<" 同学互评在80 分以上的有: "&l
62、t;<b<<endl;cout<<" 同学互评在70 分以上的有: "<<c<<endl;cout<<" 同学互评在60 分以上的有: "<<d<<endl;cout<<" 同学互评在60 分以下的有: "<<e<<endl;while(p)switch(int)p->teacher/10)case 10:case 9:a+;break;case 8:b+;break;case 7:c+;break;ca
63、se 6:d+;break;default:e+;p=p->next;cout<<" "<<endl; cout<<" 教师评分在 90 分以上的有: "<<a<<endl;cout<<" 教师评分在80 分以上的有: "<<b<<endl;cout<<" 教师评分在70 分以上的有: "<<c<<endl;cout<<" 教师评分在60 分以上的有: &q
64、uot;<<d<<endl;cout<<" 教师评分在60 分以下的有: "<<e<<endl;while(p)switch(int)p->zc/10)case 10:case 9:a+;break;case 8:b+;break;case 7:c+;break;case 6:d+;break;default:e+;p=p->next;cout<<" "<<endl;-18精选文库cout<<" 综测成绩在90 分以上的有: "<<a<<endl;cout<<" 综测成绩在80 分以上的有: "<<b<<endl;cout<<" 综测成绩在70 分以上的有: "<<c<<endl;cout<<" 综测成绩在60 分以上的有: "<<d<<endl;cout<<" 综测成绩在60 分以下的有: "<<e<<endl;cout<<" "&
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- GB/T 13399-2025汽轮机安全监视技术规范
- 妊娠合并哮喘的孕期环境控制策略
- 妊娠合并FAOD的长期随访管理策略
- 妇科肿瘤术后血栓防治策略与共识
- 大数据驱动的老年照护需求预测与伦理审查
- 大数据助力医院人力资源效率提升策略
- 多药耐药胰腺癌的吉西他滨增敏策略
- 酒店安全知识考试及答案
- 2025年大学妇幼保健学基础(妇幼保健认知)试题及答案
- 2025年中职学前教育(幼儿营养指导)试题及答案
- (正式版)DB15∕T 3463-2024 《双炉连续炼铜工艺技术规范》
- 手术部(室)医院感染控制标准WST855-2025解读课件
- 律师团队合作规范及管理办法
- 二氧化硅气凝胶的制备技术
- 临床微生物标本采集运送及处理
- 软件系统运维操作手册
- 常规体检指标讲解
- 新人教版高中数学必修第二册-第八章 立体几何初步 章末复习【课件】
- GB/T 157-2025产品几何技术规范(GPS)圆锥的锥度与锥角系列
- TD/T 1041-2013土地整治工程质量检验与评定规程
- 2025年上海市崇明区高考英语一模试卷
评论
0/150
提交评论