题目:https://www.patest.cn/contests/pat-a-practise/1011
解题思路很简单:每一场比赛进行比较,获得最大赔率
坑点:注意浮点数的输出!!!
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
double ans[3][3];
const char con[3] = {'W', 'T', 'L'};
int max_c(const double *p)
{
int l;
double max = 0;
for(int i = 0; i < 3; i++)
if(p[i] > max)
{
max = p[i];
l = i;
}
return l;
}
int main(void)
{
string line;
int flag = 0;
while(getline(cin, line))
{
double sum = 1;
stringstream ss(line);
int m = flag % 3;
for(int i = 0; i < 3; i++)
{
ss >> ans[m][i];
}
if(flag % 3 == 2)
{
for(int i = 0; i < 3; i++)
{
int col;
col = max_c(ans[i]);
sum *= ans[i][col];
cout << con[col] << " ";
}
printf("%.2f\n", (sum * 0.65-1) * 2 + 0.000001);
}
flag++;
}
return 0;
}