PTA甲级考试真题练习11——1011 World Cup Betting

题目

PTA甲级考试真题练习11——1011 World Cup Betting_第1张图片

生词生句

  1. World Cup Betting
    世界杯博彩
  2. the World Cup trophy
    世界杯奖杯
  3. Chinese Football Lottery provided a “Triple Winning” game.
    中国足球彩票提供了一个三连胜的游戏
  4. There was an odd assigned to each result
    每个结果都有一个奇数
  5. To obtain the maximum profit
    为了获得最大的利润
    6.The winner’s odd would be the product of the three odds times 65%。
    每个结果都有一个奇数。赢家的奇数将是三个赔率乘以65%的乘积。

思路

排序,绝对的水题

代码

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define nmax 100
typedef struct
{
     
	char bet;
	double odd;
}Node,NodeArray[nmax];
char s[3] = {
      'W','T','L' };

void init(NodeArray node)
{
     
	for (int i = 0; i < 3; ++i)
	{
     
		node[i].bet = s[i];
		cin >> node[i].odd;
	}
}
bool cmp(Node a, Node b)
{
     
	return a.odd > b.odd;
}
int main()
{
     
	NodeArray node1;
	NodeArray node2;
	NodeArray node3;
	init(node1);
	init(node2);
	init(node3);
	sort(node1, node1 + 3, cmp);
	sort(node2, node2 + 3, cmp);
	sort(node3, node3 + 3, cmp);
	double  sum = (node1[0].odd * node2[0].odd * node3[0].odd*0.65 - 1) * 2;
	printf("%c %c %c %.2lf", node1[0].bet, node2[0].bet, node3[0].bet, sum);
	return 0;
}

你可能感兴趣的:(PAT甲级考试真题练习)