演讲比赛评分系统 暂时10位评委 选手数量不知 每位选手上来演讲后打分 从10个分数中出去最大和最小的 算出
1个回答
展开全部
#include<stdio.h>
typedef struct judge
{
int number;
double score;
} judge;
void sort(judge Score[10])
{
int iter,iterb,temp;
double dtemp;
for(iter=0;iter<9;++iter)
{
for(iterb=0;iterb<9;++iterb)
{
if(Score[iterb].score>Score[iterb+1].score)
{
dtemp=Score[iterb].score;
Score[iterb].score=Score[iterb+1].score;
Score[iterb+1].score=dtemp;
temp=Score[iterb].number;
Score[iterb].number=Score[iterb+1].number;
Score[iterb+1].number=temp;
}
}
}
}
void print_all(judge Score[10])
{
int iter;
for(iter=0;iter<10;iter++)
{
printf("%d %.2f \n",Score[iter].number,Score[iter].score);
}
}
void main()
{
judge Score[10];
int temp,iter;
double sum=0.0,aver;
printf("请输入十位评委的分数:\n");
for(iter=0;iter<10;++iter)
{
printf("请输入%d号评委的分数:",iter+1);
scanf("%d",&temp);
if(temp<1.0||temp>100.0)
{
printf("\n输入错误,分数应该为1~100\n");
--iter;
}
else
{
Score[iter].number=iter+1;
Score[iter].score=temp;
printf("\n");
}
}
sort(Score);
// print_all(Score);
for(iter=1;iter<9;++iter)
{
sum+=Score[iter].score;
}
aver=sum/8.0;
printf("总分为%.2f,平均分为%.2f\n",sum,aver);
for(iter=0;iter<10;++iter)
{
Score[iter].score-=aver;
if(Score[iter].score<0.0)
{
Score[iter].score=-Score[iter].score;
}
}
sort(Score);
// print_all(Score);
printf("评分最公正的评委为:");
for(iter=0;iter<10;++iter)
{
printf("%d ",Score[iter].number);
if(Score[iter].score==Score[iter+1].score&&iter!=9)
{
continue;
}
else
{
break;
}
}
printf("\n评分最不公正的评委为:");
for(iter=9;iter>0;--iter)
{
printf("%d ",Score[iter].number);
if(Score[iter].score==Score[iter-1].score&&iter!=0)
{
continue;
}
else
{
break;
}
}
}
typedef struct judge
{
int number;
double score;
} judge;
void sort(judge Score[10])
{
int iter,iterb,temp;
double dtemp;
for(iter=0;iter<9;++iter)
{
for(iterb=0;iterb<9;++iterb)
{
if(Score[iterb].score>Score[iterb+1].score)
{
dtemp=Score[iterb].score;
Score[iterb].score=Score[iterb+1].score;
Score[iterb+1].score=dtemp;
temp=Score[iterb].number;
Score[iterb].number=Score[iterb+1].number;
Score[iterb+1].number=temp;
}
}
}
}
void print_all(judge Score[10])
{
int iter;
for(iter=0;iter<10;iter++)
{
printf("%d %.2f \n",Score[iter].number,Score[iter].score);
}
}
void main()
{
judge Score[10];
int temp,iter;
double sum=0.0,aver;
printf("请输入十位评委的分数:\n");
for(iter=0;iter<10;++iter)
{
printf("请输入%d号评委的分数:",iter+1);
scanf("%d",&temp);
if(temp<1.0||temp>100.0)
{
printf("\n输入错误,分数应该为1~100\n");
--iter;
}
else
{
Score[iter].number=iter+1;
Score[iter].score=temp;
printf("\n");
}
}
sort(Score);
// print_all(Score);
for(iter=1;iter<9;++iter)
{
sum+=Score[iter].score;
}
aver=sum/8.0;
printf("总分为%.2f,平均分为%.2f\n",sum,aver);
for(iter=0;iter<10;++iter)
{
Score[iter].score-=aver;
if(Score[iter].score<0.0)
{
Score[iter].score=-Score[iter].score;
}
}
sort(Score);
// print_all(Score);
printf("评分最公正的评委为:");
for(iter=0;iter<10;++iter)
{
printf("%d ",Score[iter].number);
if(Score[iter].score==Score[iter+1].score&&iter!=9)
{
continue;
}
else
{
break;
}
}
printf("\n评分最不公正的评委为:");
for(iter=9;iter>0;--iter)
{
printf("%d ",Score[iter].number);
if(Score[iter].score==Score[iter-1].score&&iter!=0)
{
continue;
}
else
{
break;
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询