【发布时间】:2020-06-25 09:36:18
【问题描述】:
**说明
first, each player draws a single card from the deck
if one of the players drew a card of the winning suit and the other did not, then the player who drew a card of the winning suit wins the round
otherwise, the numbers written on the cards decide: if one player drew a card with a greater number on it than the other player, the player with the greater number wins, otherwise, if both players drew cards with the same numbers, the round ends in a draw
after the round is ended, the players return the cards they drew into the deck
** *在第一行,有一个字符
表示获胜的花色。
在第二行,有一个整数
表示要玩的回合数。
接下来的每一个 线表示在单轮游戏中抽出的牌,包含四个以空格分隔的值: ,并表示玩家 1 牌的花色、玩家 1 牌上的数字、玩家 2 牌的花色和玩家的2张牌。 *
input:-
B
5
A 2 B 1
A 7 D 2
B 5 D 13
B 3 B 1
A 12 C 12
int main() {
char winning_suit;
std::cin >> winning_suit;
unsigned tests;
std::cin >> tests;
while (tests--) {
char suit1, suit2;
int number1, number2;
std::cin >> suit1 >> number1 >> suit2 >> number2;
auto t1 = std::make_tuple(suit1 == winning_suit, number1);
auto t2 = std::make_tuple(suit2 == winning_suit, number2);
if (t1 > t2) {
std::cout << "Player 1 wins\n";
} else if (t1 < t2) {
std::cout << "Player 2 wins\n";
} else {
std::cout << "Draw\n";
}
}
}
output:-
Player 2 wins
Player 1 wins
Player 1 wins
Player 1 wins
Draw
【问题讨论】:
-
"auto t1=std::make_tuple(case1==case2,integer)"。所以 t1 将是一个具有两个值的元组,第一个是布尔值,具有“case1==case2”比较的结果,第二个是代码中 number1 和 number2 提供的整数。我不明白你的问题是什么