也是比較簡單的一道題,只不過這道題我用的方法比較啰嗦,柳神的代碼則簡潔很多。這是我啰嗦的代碼:
#include <iostream>
using namespace std;
int main() {
int cnt;
float w, t, l, a[3][3] = {0.0};
float max[3] = {0.0}, maxp = 0.0;
for(int i = 0; i < 3; i++){
scanf("%f %f %f", &w, &t, &l);
a[i][0] = w;
a[i][1] = t;
a[i][2] = l;
}
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
if(a[i][j] > max[i]){
max[i] = a[i][j];
cnt = j;
}
}
if(cnt == 0) printf("W ");
if(cnt == 1) printf("T ");
if(cnt == 2) printf("L ");
}
maxp = max[0] * max[1] * max[2] * 0.65 * 2 - 2;
printf("%.2f", maxp);
return 0;
}
柳神的思路大概就是三個數(shù)一組讀入,讀的過程中就找出三個數(shù)中的最大值和最大值的index,然后直接進行累乘和輸出即可。