1011. World Cup Betting (20)

本文介绍了一个使用C++实现的算法案例,该算法通过查询表进行信息记录,并实现了获取最大值及其索引的功能。此外,还展示了如何利用这些信息进行特定计算并输出结果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

考察查询表以及信息记录

#include <iostream>
char g_CharTable[3] = {'W', 'T', 'L'};

void CheckCharTable()
{
	int cnt = 3;
	for(int i = 0; i < cnt; ++i)
		printf("%c\n", g_CharTable[i]);
}
int main()
{
	//CheckCharTable();
	float a[3][3];
	while(scanf("%f%f%f", &a[0][0], &a[0][1], &a[0][2]) != EOF)
	{
		for(int i = 1; i < 3; ++i)
			scanf("%f%f%f", &a[i][0], &a[i][1], &a[i][2]);
		int maxIndex[3];
		float maxValue[3];
		//get max index & value
		for(int i = 0; i < 3; ++i)
		{
			float tmpMaxValue = a[i][0];
			int tmpMaxIndex = 0;
			for(int j = 0; j < 3; ++j)
			{
				if(a[i][j] > tmpMaxValue)
				{
					tmpMaxValue = a[i][j];
					tmpMaxIndex = j;
				}
			}
			maxIndex[i] = tmpMaxIndex;
			maxValue[i] = tmpMaxValue;
		}
		//get resut 
		float ans = (maxValue[0]*maxValue[1]*maxValue[2]*0.65-1.0)*2.0;
		//output
		for(int i = 0; i < 3; ++i)
			printf("%c ", g_CharTable[maxIndex[i]]);
		//ans += 0.005;//up to 2 decimal places
		printf("%.2f\n", ans);
	}
	return 0;
}


 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI记忆

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值