小程序中的小问题
#include<stdio.h>struct player
{
int sort; //每位选手的编号
int score[5]; //每位选手的5个得分
int scoresum; //每位选手的最后得分
}player[9];
void fun(struct player player[9],int n)
{
int win,z=0;
win=player[z].scoresum;
while(z<n)
{
if(player[z].scoresum>win)
{
win=player[z].scoresum;
z++;
}
}
printf("本次大赛最高分为: %d",win);
}
void main()
{
int n,i,j,max,min,sum=0;
printf("请输入参赛选手的人数(1<n<10): \n");
scanf("%d",&n);
printf("\n");
for(i=0;i<n;i++)
{
//player[i].sort=i+1;
//scanf("%d",&player[i].sort);
printf("请输入%d号选手的得分: \n",i+1);
for(j=0;j<=4;j++)
{
scanf("%d",&player[i].score[j]);
}
for(j=0;j<=4;j++)
{
sum+=player[i].score[j];
}
max=player[i].score[0];
for(j=0;j<5;j++)
{
if(player[i].score[j]>max)
{
max=player[i].score[j];
}
}
min=player[i].score[0];
for(j=0;j<5;j++)
{
if(player[i].score[j]<min)
{
min=player[i].score[j];
}
}
player[i].scoresum=sum-max-min;
scanf("%d",&player[i].scoresum); //保存入结构体中
sum=0;
printf("去掉一个最高分: %d\n",max);
printf("去掉一个最低分: %d\n",min);
printf("%d号选手的最后得分: %d\n",i+1,player[i].scoresum);
}
//fun(player,n);
}