我的个人网站 Cheese的个人主页http://www.cheese.ren/
博客来源 PAT 乙级 1071 小赌怡情-Cheese的个人博客PAT 乙级 1071 小赌怡情http://blog.cheese.ren/91
欢迎交换友链 :-)
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, k;
scanf("%d %d", &t, &k);
int player_money = t;
while (k--) {
int n1, b, t, n2;
scanf("%d %d %d %d", &n1, &b, &t, &n2);
// Is player bankrupt?
if (player_money == 0) {
printf("Game Over.\n");
break;
}
// Does player have the enough money?
if (player_money < t) {
printf("Not enough tokens. Total = %d.\n", player_money);
continue;
}
// Yes, it has
else {
if (n1 > n2) {
if (b == 1) {
player_money -= t;
printf("Lose %d. Total = %d.\n", t, player_money);
}
else {
player_money += t;
printf("Win %d! Total = %d.\n", t, player_money);
}
}
else if (n1 < n2) {
if (b == 0) {
player_money -= t;
printf("Lose %d. Total = %d.\n", t, player_money);
}
else {
player_money += t;
printf("Win %d! Total = %d.\n", t, player_money);
}
}
}
}
return 0;
}