学生成绩管理系统的答案
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include
#include
#define STU_NUM 30
int Menu(void);
void ReadScore(long num[],float score[],int n);
void AverSumofScore(float score[],int n);
void DeSortbyScore(long num[],float score[],int n);
void AsSortbyNum(long num[],float score,int n);
void SearchbyNum(long num[],float score,int n);
void PrintScore(long num[],float score,int n);
int main()
{
char itemSelected;
int n=0;
float score[STU_NUM];
long num[STU_NUM];
printf("Input student number(n<%d):",STU_NUM);
scanf("%d",&n);
while(1)
{
itemSelected=Menu;
switch (itemSelected)
{
case 1:ReadScore(num,score,n);
break;
case 2:AverSumofScore(score,n);
break;
case 3:DeSortbyScore(num,score,n);
printf("\nSort in descending order by score:\n");
printfScore(num,score,n);
break;
case 4:AsSortbyNum(num,score,n);
printf("\nScort in ascending order by number:\n");
printfScore(num,score,n);
break;
case 5:SearchbyNum(num,score,n);
break;
case 6:StatisticAnalysis(score,n);
break;
case 7:printfScore(num,score,n);
break;
case 0:printf("End of program!\n");
exit(0);
default:printf("Input error!\n");
}
}
return 0;
}
int Menu(void)
{
int inemSelected;
printf("\nManagement for Students' scores\n");
printf("1.Input record\n")
printf("2.Caculate total and average score of course\n");
printf("3.Sort in descending order by score\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 Input your choice:");
scanf("%d",&itemSelected);
return itemSelected;
}
void Readscore(long num[],float score[],int n)
{
int i;
printf("Input student's ID and score;\n");
for (i=0;i
scanf("%ld %f",&num[i],&score[i]);
}
}
void AverSumofScore(float score[],int n)
{
int i;
float sum =0;
for (i=0;i
sum=sum+score[i];
}
printf("sum=%.0f,aver=%.2f\n",sun,n>0 ? sum/n : 0);
}
void DeSortbyScore(long num[],float score[],int n)
{
int i,j,k;
float temp1;
long temp2;
for (i=0;i
k=1;
for(j=i+1;j
if (score[j]>score[k])k=j;
}
if(k!=i)
{
temp1 =score[k];score[k] =score[i];score[i] =temp1;
temp2 =num[k];num[k]=num[i];num[i]=temp2;
}
}
}
void AsSortbyNum(long num[],float score[],int n)
{
int i,j,k;
float temp1;
long temp2;
for(i=0;i
k=i;
for(j=i+1;j
if(num[j]
temp1=score[k];score[k]=score[i];score[i]=temp1;
temp2=num[k];num[k]=num[i];num[i]=temp2;