无耻的抄袭了结果,三组数,从每一组数中选取一个数组成正六边形的对边,总共会有27个正六边形,从27个小六边形中选取19个组成大六边形,求大六边形的最大值
#include<iostream> #include<stdio.h> #include<memory.h> #include<stdlib.h> using namespace std; int t = 0; const int N = 3; int num[N][N]; int f(const void* i, const void* j) { int* ii = (int*) i; int* jj = (int*) j; return *ii > *jj; } int MAX = -1; int mark1[] = { 5, 6, 8 }; int mark2[] = { 5, 7, 7 }; int main() { cin >> t; int k = 1; while (k <= t) { MAX = -1; memset(num, 0, sizeof(num)); for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) cin >> num[i][j]; qsort(num[i], N, sizeof(int), f); } for(int i = -1; i < N; i++) { int MAX2 = 0; for(int j = 0; j < N; j++) { if(i == j) { for(int k = 0; k < N; k++) MAX2 += num[j][k] * mark1[k]; } else { for(int k = 0; k < N; k++) MAX2 += num[j][k] * mark2[k]; } } if(MAX2 > MAX) MAX = MAX2; } printf("Test #%d %d ", k, MAX); k++; } return 0; }