程序 如下,请补充数据输入部分。
#include
#include
float max3(float a,float b,float c){
float m;
m = a;
if (b>m) m=b;
if (c >m) m = c;
return m;
}
float mean3(float a,float b,float c){
float m;
m = (a + b + c) / 3.0;
return m;
}
void main()
{
float a[20][6];
float a1,a2,b[6];
float c,c_max;
int j1,j2,j3,i;
int j[3];
int N=0;
// example data 请补充数据输入部分
for (j1=0;j1<20;j1++)
for (i=0;i<6;i++) a[j1][i] = 1.0;
a[3][0]=2.;a[8][0]=2.;a[15][0]=2.;
for (j1=0;j1<20;j1++)
for (j2=1;j2<20;j2++)
for (j3=2;j3<20;j3++)
{
if (j1 == j2 || j1 == j3 || j2 == j3) continue;
for (i=0;i<6;i++)
{
a1 = max3(a[j1][i],a[j2][i],a[j3][i]) * 0.3;
a2 = mean3(a[j1][i],a[j2][i],a[j3][i]) * 0.7;
b[i] = a1+a2;
};
c=0;
for (i=0;i<6;i++) c=c + b[i];
if (N==0) {c_max = c;
j[0]=j1; j[1]=j2; j[2]=j3;
} else {
if (c > c_max) { c_max= c; j[0]=j1; j[1]=j2; j[2]=j3;};
}
N = N + 1;
}
printf("%d %d %d\n",j[0],j[1],j[2]);
}
程序 还是 数学?
有点ACM性质的题目。