各位大佬,我实在看不懂怎么错,求助
#include<stdio.h>#define N 30
void Readscore(int id[],int score[],int n);/*录入每个学生的学号和考试成绩*/
int Average(int score[],int n);/*计算平均分*/
int a1(int score[],int n);/*计算总分*/
void Datasort1(int id[],int score[],int n);/*进行成绩排序*/
void Datasort2(int id[],int score[],int n);/*进行学号排序*/
int Selectsort(int id[],int score[],int n,int x); /*按照学号查询排名以及考试成绩*/
void Scoreclass(int score[],int n);/*分出分数段*/
void Showinfo(int id[],int score[],int n); /*输出每个学生的学号和成绩*/
int main()
{
int num,score[N],aver,n,SUM,id[N],i,m,k,great=0,better=0,middle=0,low=0,lower=0,x;
while(1){
//首页选择
printf("----------------\n");
printf("1.录入学生的学号和成绩\n");
printf("2.学生课程的总分和平均分\n");
printf("3.按分数降序排列\n");
printf("4.按数字升序排序\n");
printf("5.查询学号\n");
printf("6.统计分析\n");
printf("7.数据列表\n");
printf("0.退出\n");
printf("请进入你的选择\n");
scanf("%d",&num);
//用户输入功能
switch(num)
{
case 0:
break;
case 1:
printf("输入人数 n:\n");
scanf("%d",&n);
Readscore(id,score,n);
break;
case 2:
aver=Average(score,n),SUM=a1(score,n);
printf("课程的总分为%d,平均分为%d\n",&SUM,&aver);
break;
case 3:
Datasort1(id,score,n);
for(i=0;i<=n-1;i++)
{
printf("%3d%5d\n",id[i],score[i]);/*输出成绩排序结果*/
}
break;
case 4:
Datasort2(id,score,n);
for(i=0;i<=n-1;i++)
{
printf("%3d%5d\n",id[i],score[i]);/*输出学号和成绩*/
}
break;
case 5:
printf("Input id:\n");
scanf("%d",&x);
m=Selectsort(id,score,n,x);
if(m==-1)
{
printf("查询错误\n");
}else
{
printf("----------------\n");
printf("id:%3d score:%3d 排名:%3d\n",id[m],score[m],m+1);
}
break;
case 6:
Scoreclass(score,n);
break;
case 7:
Showinfo(id,score,n);
sum=Average(score,n);
printf("----------------\n");
printf("Sum score is %d\n",sum);
printf("Average score is %d\n",sum/n);
break;
default:
printf("无效的操作符\n");
}
}
}
void Readscore(int id[],int score[],int n)/*通过函数记录学生的学号和成绩,当输入为负值时结束输入,并且返回学生人数*/
{
int i;
for(i=0;i<n;i++)
{
printf("输入学生的学号和成绩:");
scanf("%d %d",&id[i],&score[i]);
if(score[i]<0)
{
printf("成绩输入错误\n");
}
}
}
int Average(int score[],int n)
{
int i,sum=0;
for(i=0;i<n;i++)
{
sum+=score[i];
}
return n>0?sum/n:-1;
}
int a1(int score[],int n)
{
int i,sum=0;
for(i=0;i<n;i++)
{
sum+=score[i];
}
return sum;
}
void Datasort1(int id[],int score[],int n)
{
int i,j,temp;
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(score[j]>score[i])
{
temp=score[j];
score[j]=score[i];
score[i]=temp;
}
}
}
}
void Datasort2(int id[],int score[],int n)
{
int temp_score,i,j,temp_id,k,x;
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(score[i]<score[j])
{
temp_score = score[i];
score[i]=score[j];
score[j]=temp_score;
temp_id=id[i];
id[i]=id[j];
id[j]=temp_id;
}
}
}
for(k=0;k<n;k++)
{
if(id[k]==x)
return k;
}
return -1;
}
int Selectsort(int id[],int score[],int n,int x)
{
int temp_score,i,j,temp_id,k,x;
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(score[i]<score[j])
{
temp_score = score[i];
score[i]=score[j];
score[j]=temp_score;
temp_id=id[i];
id[i]=id[j];
id[j]=temp_id;
}
}
}
for(k=0;k<n;k++)
{
if(id[k]==x)
return k;
}return -1;
}
void Scoreclass(int score[],int n)
{
int i,j,count,k;
double bate,m;
m=n;
int begin[5]={0,60,70,80,90};
int end[5]={59,69,79,89,100};
char* class[5]={"不及格","及格","中等","良好","优秀"};
for(i=0,j=0;i<=n,j<5;i++,j++)
{
count =0;
bate=0;
for(k=0;k<n;k++)
{
if((begin[i]<=score[k])&&(end[i]>=score[k]))
{
count+=1;
bate=(100*count)/m;
}
}
printf("%s的学生人数为:%d ,所占百分比为%.2f\n",class[j],count,bate/100);
}
}
void Showinfo(int id[],int score[],int n)
{
int i;
for(i=0;i<=n-1;i++)
{
printf("id:%3d score:%3d\n",id[i],score[i]);
}
}