各位可不可以帮我解这一题呀? 太难了
Consider a game in which there is a prize worth $20. There are three contestants, Mary, Tom, and Tina. Each can buy a ticket worth $10 or $20 or not buy a ticket at all. They make these choices simultaneously and dependently. Then, knowing the ticket-purchase decisions, the game organizer awards the prize. If no one has bought a ticket, the prize is not awarded. Otherwise, the prize is awarded to the buyer of the highest-cost ticket if there is only one such player or is split equally between two or three if there are ties among the highest-cost ticket buyers. Show this game in strategic form, using Larry as the row player, Curly as the column player, and Moe as the page player.
// caimi8.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <vector>
#include <string>
using namespace std;
void JudgeVec(vector<int> vec,vector<int>& vecRE)
{
if (vec[0]>vec[1] && vec[0]>vec[2]) // 0位置胜出
{
vecRE.push_back(0);
}
else if (vec[1]>vec[0] && vec[1]>vec[2]) // 1位置胜出
{
vecRE.push_back(1);
}
else if (vec[2]>vec[0] && vec[2]>vec[1]) // 2位置胜出
{
vecRE.push_back(2);
}
else if (vec[0] == vec[1] && vec[0] == vec[2] && vec[0] == 0)
{
if (vec[0] == 0) // 都没出钱
{
}
}
else if (vec[0] == vec[1] && vec[0] > vec[2] && vec[0] != 0)
{
vecRE.push_back(0);
vecRE.push_back(1);
}
else if (vec[0] == vec[2] && vec[0] > vec[1] && vec[0] != 0)
{
vecRE.push_back(0);
vecRE.push_back(2);
}
else if (vec[1] == vec[2] && vec[1] > vec[0] && vec[1] != 0)
{
vecRE.push_back(1);
vecRE.push_back(2);
}
else if (vec[0] == vec[1] && vec[0] == vec[2])
{
if (vec[0] != 0) // 都出钱 平均分
{
vecRE.push_back(0);
vecRE.push_back(1);
vecRE.push_back(2);
}
}
}
int _tmain(int argc, _TCHAR* argv[])
{
vector<string> vec1;
vec1.push_back("\\");
vec1.push_back("Mary");
vec1.push_back("Tom");
vec1.push_back("Tina");
vec1.push_back("result");
// 价格
vector<int> vecPrices = {0,10,20};
int length = 3 * 3 * 3;
vector<vector<int>> vec2;
vec2.resize(length, vector<int>(3, 0));
for (size_t i = 0; i < length; i++)
{
for (size_t j = 1; j <=3; j++)
{
int iTempGe = 0;
if (j==1)
{
iTempGe = i % 3;
}
else
{
iTempGe = (int)(i / pow(3, j - 1)) % (int)pow(3, j - 1);
}
if (iTempGe >= 10)
{
iTempGe = iTempGe % 10;
}
vec2[i][j-1] = vecPrices[iTempGe];
int a = 0;
}
}
// 打印标题
printf(" %s", vec1[0].c_str());
printf(" %s", vec1[1].c_str());
printf(" %s", vec1[2].c_str());
printf(" %s", vec1[3].c_str());
printf(" %s", vec1[4].c_str());
printf("\n");
for (size_t i = 0; i < length; i++)
{
printf("%2d", i);
for (size_t j = 1; j <= 3; j++)
{
int iWri = vec2[i][j - 1];
if (iWri>9)
{
printf(" %d", iWri);
}
else
{
printf(" %d", iWri);
}
}
vector<int> vectempJudge;
JudgeVec(vec2[i], vectempJudge);
printf(" ");
if (vectempJudge.size() == 1)
{
printf("%s一人得到票", vec1[vectempJudge[0]+1].c_str());
}
if (vectempJudge.size() == 2)
{
printf("%s和%s两人得到票", vec1[vectempJudge[0] + 1].c_str(), vec1[vectempJudge[1] + 1].c_str());
}
if (vectempJudge.size() == 3)
{
printf("%s,%s和%s三人得到票", vec1[vectempJudge[0] + 1].c_str(),
vec1[vectempJudge[1] + 1].c_str(),
vec1[vectempJudge[2] + 1].c_str());
}
if (vectempJudge.size() == 0)
{
printf("无得到票");
}
printf("\n");
}
_tsystem(L"pause");
return 0;
}