新人程序求助~!
这是一个打分程序,n个评委评分,去掉最高分,最低分,然后求平均分。 我自己写了一个,运行结果不对,求各位高手指点
#include<stdio.h>
void main()
{
int a[100],n,i,total,max,min,grade;
scanf("%d",&n);
printf("there are %d judges\n",n);
if(n<=2)
printf("data error\n");
else
printf("please input grades\n");
for(i=1,total=0;i<=n;i++)
{
scanf("%d",&a[i]);
printf("number %d judge give %d scores\n",i,a[i]);
total=total+a[i];
}
max=a[1];
for(i=1;i<=n;i++)
{
if(max<a[i+1])
max=a[i+1];
}
printf("the highest grade is %d\n",max);
min=a[1];
for(i=1;i<=n;i++)
{
if(min>a[i+1])
min=a[i+1];
}
printf("the lowest grade is %d\n",min);
grade=(total-max-min)/(n-2);
printf("the final grade is %d\n",grade);
}