学生成绩管理系统 V 1.0

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include
void xhcj(int n,long number[],int score[]);
float total(int n,int score[]);
float average(int n,int score[]);
void scorepaixu(int n,int score[],long number[]);
void numberpaixu(int n,int score[],long number[]);
int chaxun(long number[],int n,long studentnumber);
void fenleibai(int n,int score[],int ylzjb[]);
#define N 30
main()
{
int n,m,i;
int score[N]={0};
int ylzjb[5]={0};
long number[N]={0},studentnumber;
printf("please input the number about student\n");
scanf("%d",&n);
do{
printf("1. input record \n");
printf("2. caculate total and average score of course \n");
printf("3. sort in descending order by number \n");
printf("4. sort in ascending order by number \n");
printf("5.search by number \n");
printf("6. statistic analysis \n");
printf("7. list record \n");
printf("0. exit \n");
printf("please enter your choice : ");
scanf("%d",&m);
switch(m)
{
case 1:
xhcj(n,number,score);
break;
case 2:
printf("total=%.0f\n",total(n,score));
printf("average=%.1f\n",average(n,score));
break;
case 3:
scorepaixu(n,score,number);
for(i=0;i{
printf(" 第%d名 %d %d\n",i+1,number[i],score[i]);
}
break;
case 4:
numberpaixu(n,score,number);
for(i=0;i{
printf("%d %d\n",number[i],score[i]);
}
break;
case 5:
scorepaixu(n,score,number);
printf("please iinput studentnumber:");
scanf("%ld",&studentnumber);
i=chaxun(number,n,studentnumber);
if(i==-1)
{
printf("studentnumber is error");
}
else
{
printf("排名%d ,成绩%d\n",i+1,score[i]);
}
break;
case 6:
fenleibai(n,score,ylzjb);
printf("优秀有%d个,占%.2f%%\n",ylzjb[0],(float)(100/n)*ylzjb[0]);
printf("良好有%d个,占%.2f%%\n",ylzjb[1],(float)(100/n)*ylzjb[1]);
printf("中等有%d个,占%.2f%%\n",ylzjb[2],(float)(100/n)*ylzjb[2]);
printf("及格有%d个,占%.2f%%\n",ylzjb[3],(float)(100/n)*ylzjb[3]);
printf("不及格有%d个,占%.2f%%\n",ylzjb[4],(float)(100/n)*ylzjb[4]);
break;
case 7:
for(i=0;i{
printf("%d %d\n",number[i],score[i]);
}
printf("total=%.0f\n",total(n,score));
printf("average=%.1f\n",average(n,score));
break;
case 0:
break;
}
}while(m!=0);
}
/* 函数功能:录入学生的学号和成绩*/
void xhcj(int n,long number[],int score[])
{
int i;
for(i=0;i{
printf("please input number:");
scanf("%ld",&number[i]);
printf("\n");
printf("please input score:");
scanf("%d",&score[i]);
printf("\n");
}
}
/*函数功能:计算课程总分*/
float total(int n,int score[])
{
int i;
float sum=0;
for(i=0;i{
sum=sum+score[i];
}
return sum;
}
/*函数功能:计算平均分*/
float average(int n,int score[])
{
int j;
float i;
float sum=0;
for(j=0;j{

sum=sum+score[j];
}
i=(float)sum/n;
return i;
}
/*函数功能:按成绩高低排序*/
void scorepaixu(int n,int score[],long number[])
{
int i,ters,term,ret;
do
{
ret=0;
for(i=0;i{
if(score[i]{
ters=score[i+1];
score[i+1]=score[i];
score[i]=ters;
term=number[i+1];
number[i+1]=number[i];
number[i]=term;
ret++;
}
}
}while(ret!=0);
}
/*函数功能:按学号大小排序*/
void numberpaixu(int n,int score[],long number[])
{
int i,ters,term,ret;
do
{
ret=0;
for(i=0;i{
if(number[i]>number[i+1])
{
ters=score[i+1];
score[i+1]=score[i];
score[i]=ters;
term=number[i+1];
number[i+1]=number[i];
number[i]=term;
ret++;
}
}
}while(ret!=0);
}
/*函数功能:查询学生排名和成绩*/
int chaxun(long number[],int n,int studentnumber)
{
int i,ret=0;
for(i=0;i{
if(number[i]==studentnumber)
{
return i;
ret++;
}
}
if(ret==0)
{
return -1;
}
}
/*函数功能:学生成绩分类*/
void fenleibai(int n,int score[],int ylzjb[])
{
int i;
for(i=0;i{
if(score[i]>=90&&score[i]<=100)
{
ylzjb[0]++;
}
if(score[i]>=80&&score[i]<=89)
{
ylzjb[1]++;
}
if(score[i]>=70&&score[i]<=79)
{
ylzjb[2]++;
}
if(score[i]>=60&&score[i]<=69)
{
ylzjb[3]++;
}
if(score[i]>=0&&score[i]<=59)
{
ylzjb[4]++;
}
}
}

相关文档
最新文档