0.038774 0.040669 0.033874 0.036969 0.036637 0.040109 0.042759
0.03697 0.039313 0.043416 0.032348 0.039925 0.041477 0.041379
0.036069 0.033891 0.041985 0.042976 0.040395 0.035552 0.035862
0.040577 0.039765 0.045324 0.036506 0.036167 0.037375 0.041379
0.039225 0.037506 0.042939 0.039741 0.030531 0.038286 0.041839
0.040577 0.041121 0.034828 0.030961 0.036167 0.040565 0.037241
0.039675 0.039313 0.040553 0.039741 0.042273 0.042844 0.03908
0.041028 0.039765 0.033397 0.030037 0.028652 0.035552 0.038621
0.032913 0.040217 0.043416 0.040203 0.041334 0.035552 0.036782
0.039225 0.039765 0.042939 0.042052 0.038985 0.038286 0.04092
0.036069 0.039313 0.034351 0.04159 0.040395 0.038286 0.036322
0.039225 0.040669 0.038168 0.037893 0.037107 0.041021 0.036782
0.042831 0.035246 0.041985 0.04159 0.035698 0.035552 0.028966
0.04193 0.041573 0.036737 0.037893 0.039455 0.041021 0.04046
0.035167 0.038409 0.040076 0.041128 0.034288 0.040109 0.038161
0.039675 0.040669 0.037691 0.038355 0.040864 0.03464 0.036782
0.042831 0.035246 0.042939 0.042052 0.036637 0.03783 0.03908
0.039675 0.034794 0.042462 0.039279 0.038985 0.041021 0.035862
0.041479 0.040217 0.033397 0.034658 0.036637 0.041933 0.04046
0.040126 0.042024 0.035782 0.036969 0.040864 0.040565 0.04092
0.042831 0.039765 0.03626 0.036969 0.034758 0.039198 0.035862
#include "stdafx.h"
#include<iostream>
#define MAX(a,b,c) ((((a>b)?(a):(b))>c)?((a>b)?(a):(b)):(c))
const int Num = 1330;
using namespace std;
FILE *fin=fopen("input.txt","r");
FILE *temp=fopen("output.txt","w");
int n = 21;
int r = 3;
int x, y ,z=0;
double innub[7][21];
double w[7]={0.3504,0.2375,0.1590,0.1056,0.0696,0.0462,0.0318};//权重矩阵
char name[22]="ABCDEFGHIKMNPQRTUVWXZ";
double M[11][1331],t[11],del[21];
int C[21];
char used[21];
void combine(int pos, int h)
{
int i;
if (pos==r) {
M[7][z]=0;
for(x = 0; x < 7; x++ )
{
M[x][z]=MAX(innub[x][C[0]-1],innub[x][C[1]-1],innub[x][C[2]-1]);
// fprintf(temp,"%.7lf ",M[x][z]);
M[7][z]=M[7][z]+M[x][z]*w[x];
}
M[8][z]=C[0];
M[9][z]=C[1];
M[10][z]=C[2];
// fprintf(temp,"| M*Wo=%.7lf |%c %c %c \n",M[7][z],name[C[0]-1],name[C[1]-1],name[C[2]-1]);
z++;
return;
}
for (i=h; i<=n-r+pos+1; i++)
if (!used[i])
{
C[pos] = i;
used[i]++;
combine(pos+1,i+1);
used[i]--;
}
}
int main(){
int i;
for (i = 0; i < 21; i ++)
{
C[i] = i+1;
}
for(y = 0; y < 21; y ++)
{
for(x = 0; x < 7; x++ )
fscanf(fin,"%lf",&innub[x][y]);//读取input.txt数据
}
combine(0,1);
n=1;
for(i=0;i<21;i++)
{
for(z=0;z<1331;z++)
{
for(y=0;y<i;y++)
{
if(del[y]==M[8][z] || del[y]==M[9][z] || del[y]==M[10][z])
{y=i;n=0;}
else n=1;
}
if(n==1 && M[7][z]>t[7])
{
for(x = 0; x < 11; x++ )
t[x]=M[x][z];
}
}
for(x = 0; x < 7; x++ )
fprintf(temp,"%.7lf ",t[x]);
fprintf(temp,"| M*Wo=%.7lf |%c %c %c \n",t[7],name[int(t[8])-1],name[int(t[9])-1],name[int(t[10])-1]);
del[i]=t[8];
del[i+1]=t[9];
del[i+2]=t[10];
// fprintf(temp,"|i=%d|del=%.7lf,%.7lf,%.7lf \n",i,del[i],del[i+1],del[i+2]);
i=i+2;
t[7]=0;
}//
return 0;
}