帮我看看错在哪?第三个调用函数有问题?
#include<iostream.h>#include<stdio.h>
#include<string.h>
#include<iomanip.h>
void input_data(char name[3][20],float score[3][5]);
void max_min(float Score[3][5]);
void sort(float end_score[3],char name[3][20]);
void main()
{
char name[3][20];
float score[3][5],end_score[3];
input_data(name,score);
max_min(score);
sort(end_score,name);
}
void input_data(char name[3][20],float score[3][5])//输入5位评委给3位选手的评分.
{
int i,j;
for(i=0;i<3;i++)
{
cout<<"请输入第"<<i+1<<"位选手的姓名:"<<endl;
gets(name[i]);
cout<<"请输入第"<<i+1<<"位选手的各个评委给分:"<<endl;
for(j=0;j<5;j++)
{
cin>>score[i][j];
}
}
}
void max_min(float Score[3][5])//找出每位选手的最高分,最低分,最后得分.
{
int i,j;
float a=0,b=10,c=0;
float max[3],min[3],sum[3],end_score[3];
for(i=0;i<3;i++)
{
for(j=0;j<5;j++)
{
if(a<Score[i][j])
a=Score[i][j];
if(b>Score[i][j])
b=Score[i][j];
c+=Score[i][j];
}
max[i]=a;
min[i]=b;
sum[i]=c;//第i+1号选手的总分.
end_score[i]=((sum[i]-max[i]-min[i])/3);//第i+1号选手的最后得分(除去最高,最低的平均数).
a=0;
b=10;
c=0;
}
cout<<"各选手比赛的基本情况如下:"<<endl;
cout<<" ______________________________________________________________________"<<endl;//打印表格
for(i=0;i<3;i++)
{
cout<<"| "<<i+1<<"号选手: | 最高得分: "<<setiosflags(ios::fixed)<<setprecision(2)<<max[i]<<" | 最低得分: "<<setiosflags(ios::fixed)<<setprecision(2)<<min[i]<<" | 最后得分: "<<setiosflags(ios::fixed)<<setprecision(2)<<end_score[i]<<" |"<<endl;
cout<<"|______________________________________________________________________|"<<endl;
}
cout<<endl;
}
void sort(float end_score[3],char name[3][20])//由高到低显示最后得分排序(显示名次,姓名,最后得分)
{
int i,j;
float t;
char c[1][20]={0};
for(j=0;j<2;j++)//起泡
{
for(i=0;i<=3-j;i++)
{
if(end_score[i]<end_score[i+1])
{
t=end_score[i];
end_score[i]=end_score[i+1];
end_score[i+1]=t;
strcpy(c[0],name[i]);
strcpy(name[i],name[i+1]);
strcpy(name[i+1],c[0]);
}
}
}
cout<<"最后排名情况如下:"<<endl;
cout<<"________________________________________________"<<endl;
for(i=0;i<3;i++)
{
cout<<"| 第"<<i+1<<"名 | 姓名: "<<setiosflags(ios::left)<<setw(8)<<name[i]<<" | 最后得分:"<<setiosflags(ios::fixed)<<setprecision(2)<<end_score[i]<<" |"<<endl;
cout<<"|_______________________________________________|"<<endl;
}
cout<<endl;
}