//成绩管理系统v3.0// 能动1302 王清栋1306030217#include <stdio.h>#include <stdlib.h>#include <string.h>#define N 30void Input (long num[],int score[],int n,char name[][10]);void Totalave (int score[],int n);void Scoredes (long num[],int score[],int n,char name[][10]);void Scoreas (long num[],int score[],int n,char name[][10]);void Numas (long num[],int score[],int n,char name[][10]);void Nameorder(long num[],int score[],int n,char name[][10]) ;void Searchbyno (long num[],int score[],int n,int x,char name[][10]); void Searchbyname(long num[],int score[],int n,char c[],char name[][10]); void statistis (int score[],int n);void List (long num[],int score[],int n,char name[][10]);int main(){int n,score[N],c,x;long num[N];char name[N][10];char y[10];printf("输入学生人数");scanf("%d",&n);// getchar();printf("1.Input record\n");printf("2.Caculate totel and average score of every course\n");printf("3.Sort in descending order by score\n");printf("4.Sort in ascending order by score \n");printf("5.Sort in ascending order by number\n");printf("6.Sort in dictionary order by name\n");printf("7.Search by number\n");printf("8.search by name\n");printf("9.Statistic analysis\n");printf("10.List record\n");printf("0.Exit\n");printf("Please enter your choice:\n");printf("\n");for(;;){scanf("%d",&c);switch(c){case 1: //录入学生学号和各科成绩Input (num,score,n,name);printf("Please enter your choice:\n");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 your 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("%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: //成绩分析所占百分比statistis (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 name[][10]) //1{int i;for(i=0;i<n;i++){printf("Input student's ID ,name and score");scanf("%ld",&num[i]);scanf("%s",name[i]);scanf("%d",&score[i]);//getchar();}}void Totalave (int score[],int n) //2.计算课程的总分和平均分{int i,sum=0;double ave;for(i=0;i<n;i++){sum=sum+score[i];}ave=(double)sum/n;printf("总分=%d,课程的平均分=%f\n",sum,ave);}void Scoredes (long num[],int score[],int n,char name[][10]) //3.按学生的分由高到低排出名次表{int i,j,k,t,h;char temp[10];for(i=0;i<n;i++){k=i;for(j=i+1;j<n;j++){if (score[j]>score[k])k=j;}if(i!=k){t=score[k],h=num[k],strcpy(temp,name[k]);score[k]=score[i],num[k]=num[i],strcpy(name[k],name[i]);score[i]=t,num[i]=h,strcpy(name[i],temp);}}for(i=0;i<n;i++)printf("ID:%10ld,name:%s,score:%d\n",num[i],name[i],score[i]);//以长整形打印用%ld }void Scoreas (long num[],int score[],int n,char name[][10]) //4.按学生的分由高到低排出名次表{int i,k,t,h,j;char temp[10];for(i=0;i<n;i++){k=i;for(j=i+1;j<n;j++){if (score[j]<score[k])k=j;}if(i!=k){t=score[k],h=num[k],strcpy(temp,name[k]);score[k]=score[i],num[k]=num[i],strcpy(name[k],name[i]);score[i]=t,num[i]=h,strcpy(name[i],temp);}}for(i=0;i<n;i++)printf("ID:%10ld,name:%s,score:%d\n",num[i],name[i],score[i]);//以长整形打印用%ld }void Numas (long num[],int score[],int n,char name[][10]) //5.按学号由小到大排出名次表{int i,k,h,t,j;char temp[10];for(i=0;i<n;i++){k=i;for(j=i+1;j<n;j++){if (num[j]<num[k])k=j;}if(i!=k){t=score[k],h=num[k],strcpy(temp,name[k]);score[k]=score[i],num[k]=num[i],strcpy(name[k],name[i]);score[i]=t,num[i]=h,strcpy(name[i],temp);}}for(i=0;i<n;i++){printf("ID:%10ld,name:%s,score:%d\n",num[i],name[i],score[i]);//以长整形打印用%ld }}void Nameorder(long num[],int score[],int n,char name[][10]) //6。