1011 World Cup Betti
作者:互联网
1011 World Cup Betting
For example, 3 games’ odds are given as the following:
W T L
1.1 2.5 1.7
1.2 3.1 1.6
4.1 1.2 1.1
To obtain the maximum profit, one must buy W
for the 3rd game, T
for the 2nd game, and T
for the 1st game. If each bet takes 2 yuans, then the maximum profit would be (4.1×3.1×2.5×65%−1)×2=39.31 yuans (accurate up to 2 decimal places).
Sample Input:
1.1 2.5 1.7
1.2 3.1 1.6
4.1 1.2 1.1
Sample Output:
T T W 39.31
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
struct odds
{
float w;
float t;
float l;
float max;
}games[3];
float Max(odds item)
{
if (item.w > item.t && item.w > item.l)
return item.w;
else if (item.t > item.l)
return item.t;
else
return item.l;
}
int main()
{
float re = 0.65;
char re_c[3];
for (int i = 0; i < 3; i++)
{
scanf_s("%f%f%f", &games[i].w, &games[i].t, &games[i].l);
if (games[i].w > games[i].t && games[i].w > games[i].l)
{
re_c[i] = 'W';
re *= games[i].w;
}
else if (games[i].t > games[i].l)
{
re_c[i] = 'T';
re *= games[i].t;
}
else
{
re_c[i] = 'L';
re *= games[i].l;
}
}
re = (re - 1) * 2;
for (int i = 0; i < 3; i++)
{
printf("%c ", re_c[i]);
}
printf("%.2f\n", re);
}
标签:Betti,1.2,re,float,item,games,World,1011,1.1 来源: https://blog.csdn.net/weixin_44230791/article/details/122708109