版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、/成绩管理系统v3.0 / 能动1302 王清栋 1306030217#include <stdio.h>#include <stdlib.h>#include <string.h>#define N 30void Input (long num,int score,int n,char name10);void Totalave (int score,int n);void Scoredes (long num,int score,int n,char name10);void Scoreas (long num,int score,int n,char
2、name10);void Numas (long num,int score,int n,char name10);void Nameorder(long num,int score,int n,char name10) ;void Searchbyno (long num,int score,int n,int x,char name10);void Searchbyname(long num,int score,int n,char c,char name10);void statistis (int score,int n);void List (long num,int score,i
3、nt n,char name10);int main() int n,scoreN,c,x; long numN; char nameN10; char y10; printf("输入学生人数"); scanf("%d",&n); / getchar(); printf("1.Input recordn"); printf("2.Caculate totel and average score of every coursen"); printf("3.Sort in descending ord
4、er by scoren"); printf("4.Sort in ascending order by score n"); printf("5.Sort in ascending order by numbern"); printf("6.Sort in dictionary order by namen"); printf("7.Search by numbern"); printf("8.search by namen"); printf("9.Statistic a
5、nalysisn"); printf("10.List recordn"); printf("0.Exitn"); printf("Please enter your choice:n"); printf("n"); for(;) scanf("%d",&c); switch(c) case 1: /录入学生学号和各科成绩1 / 8 Input (num,score,n,name); printf("Please enter your choice:n");
6、 break; case 2: /计算每门课程的总分和平均分 Totalave (score,n); printf("Please enter your choice:n"); break; case 3: /按chengji由高到低排出名次表 Scoredes (num,score,n,name); printf("Please enter your choice:n"); break; case 4: /按chengji由低到高排出名次表 Scoreas (num,score,n,name); printf("Please enter yo
7、ur choice:n"); break; case 5: /按学号由小到大排出名次表 Numas (num,score,n,name); printf("Please enter your choice:n"); break; case 6: /按学号由小到大排出名次表 Nameorder (num,score,n,name); printf("Please enter your choice:n"); break; case 7: /按学号查询学生排名及其各科成绩 printf("请输入查找学号n"); scanf(&q
8、uot;%d",&x); Searchbyno (num,score,n,x,name); printf("Please enter your choice:n"); break; case 8: /按姓名查询学生排名及其各科成绩 printf("请输入查找姓名n"); getchar(); gets(y); Searchbyname (num,score,n,y,name); break; printf("Please enter your choice:n"); case 9: /成绩分析 所占百分比 stati
9、stis (score,n); printf("Please enter your choice:n"); break; case 10: /全部输出 List (num,score,n,name); printf("Please enter your choice:n"); break; case 0: exit(0); return 0; void Input (long num,int score,int n,char name10) /1 int i; for(i=0;i<n;i+) printf("Input student
10、39;s ID ,name and score"); scanf("%ld",&numi); scanf("%s",namei); scanf("%d",&scorei); /getchar(); void Totalave (int score,int n) /2.计算课程的总分和平均分 int i,sum=0; double ave; for(i=0;i<n;i+) sum=sum+scorei; ave=(double)sum/n; printf("总分=%d,课程的平均分=%fn&qu
11、ot;,sum,ave);void Scoredes (long num,int score,int n,char name10) /3.按学生的分由高到低排出名次表 int i,j,k,t,h; char temp10; for(i=0;i<n;i+) k=i; for(j=i+1;j<n;j+) if (scorej>scorek) k=j; if(i!=k) t=scorek,h=numk,strcpy(temp,namek); scorek=scorei,numk=numi,strcpy(namek,namei); scorei=t,numi=h,strcpy(nam
12、ei,temp); for(i=0;i<n;i+) printf("ID:%10ld,name:%s,score:%dn",numi,namei,scorei);/以长整形打印用%ldvoid Scoreas (long num,int score,int n,char name10) /4.按学生的分由高到低排出名次表 int i,k,t,h,j; char temp10; for(i=0;i<n;i+) k=i; for(j=i+1;j<n;j+) if (scorej<scorek) k=j; if(i!=k) t=scorek,h=numk,
13、strcpy(temp,namek); scorek=scorei,numk=numi,strcpy(namek,namei); scorei=t,numi=h,strcpy(namei,temp); for(i=0;i<n;i+) printf("ID:%10ld,name:%s,score:%dn",numi,namei,scorei);/以长整形打印用%ldvoid Numas (long num,int score,int n,char name10) /5.按学号由小到大排出名次表 int i,k,h,t,j; char temp10; for(i=0;i&
14、lt;n;i+) k=i; for(j=i+1;j<n;j+) if (numj<numk) k=j; if(i!=k) t=scorek,h=numk,strcpy(temp,namek); scorek=scorei,numk=numi,strcpy(namek,namei); scorei=t,numi=h,strcpy(namei,temp); for(i=0;i<n;i+) printf("ID:%10ld,name:%s,score:%dn",numi,namei,scorei);/以长整形打印用%ld void Nameorder(long
15、num,int score,int n,char name10) /6。按姓名的字典顺序排出成绩表 int i,k,t,h; char temp10; for(i=0;i<n;i+) for(k=i+1;k<n;k+) if(strcmp(namei,namek)>0) t=scorek,h=numk,strcpy(temp,namek); scorek=scorei,numk=numi,strcpy(namek,namei); scorei=t,numi=h,strcpy(namei,temp); for(i=0;i<n;i+) printf("ID:%10
16、ld,name:%s,score:%dn",numi,namei,scorei);/以长整形打印用%ld void Searchbyno (long num,int score,int n,int x,char name10) /7.按学号查询学生排名及考试成绩 int high=n-1,low=0,mid,c=1,pos,find=0,i,k,h,j,t; char temp10; for(i=0;i<n;i+) k=i; for(j=i+1;j<n;j+) if (numj<numk) k=j; if(i!=k) t=scorek,h=numk,strcpy(t
17、emp,namek); scorek=scorei,numk=numi,strcpy(namek,namei); scorei=t,numi=h,strcpy(namei,temp); while(find=0&&low<=high) mid=(high+low)/2; if(x>nummid) low=mid+1; else if(x<nummid) high=mid-1; else pos=mid; find=1; if(find=0) printf("not findn"); else for(i=0;i<n;i+) if(sc
18、orei>scorepos) c+; printf("ID:%10ld,name:%s,order:%d,",numpos,namepos,c);/以长整形打印用%ld printf("score:%dn",scorepos); void Searchbyname(long num,int score,int n,char c,char name10)/8。按姓名查询学生排名及其考试成绩 int i,pos=-1,d=1; for(i=0;i<n;i+) if(strcmp(namei,c)=0) pos=i; if(pos=-1) prin
19、tf("not findn"); else for(i=0;i<n;i+) if(scorei>scorepos) d+; printf("ID:%10ld,name:%s,order:%d,",numpos,namepos,d);/以长整形打印用%ld printf("score:%dn",scorepos);void statistis (int score,int n) /9.案优秀良好中等及格不及格5个类别,统计每个类别的人数以及所占的百分比 int a=0,b=0,c=0,d=0,e=0,i; double A,B,C,D,E; for(i=0;i<n;i+) if(scorei>=90) a+; else if(scorei>=80) b+; else if
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论