jeudi 25 juin 2020

what is value of auto t1=std::make_tuple(case1==case2,integer)

**DISCRIPTION

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

** *In the first line, there is a single character

denoting the winning suit.

In the second line, there is a single integer

denoting the number of rounds to be played.

Each of the next lines denotes the cards that were drawn in a single round of the game and contains four space-separated values: , and denoting the suit of player's 1 card, the number on player's 1 card, the suit of player's 2 card, and the number of player's 2 card respectively. *

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

Aucun commentaire:

Enregistrer un commentaire