题目链接:1071 小赌怡情
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int T, K, n1, n2, b, t;
cin >> T >> K;
for(int i=0;i<K;i++){
cin >> n1 >> b >> t >> n2;
if(T == 0) continue;
if(t > T) printf("Not enough tokens. Total = %d.\n",T);
else if((b && n1 < n2)||(!b && n1 > n2)){
T += t;
printf("Win %d! Total = %d.\n", t, T);
}
else{
T -= t;
printf("Lose %d. Total = %d.\n", t, T);
if(!T)printf("Game Over.\n");
}
}
return 0;
}
本文提供了一个名为“1071 小赌怡情”的编程题目的解决方案。该程序使用C++实现,通过输入玩家的初始代币数、游戏轮次及每轮的赌注、胜负条件等来模拟赌博过程,并根据结果输出赢得或失去的代币数,最终判断游戏是否结束。

211

被折叠的 条评论
为什么被折叠?



