1 条题解

  • 0
    @ 2024-11-2 20:49:07

    唐式做法

    #include <iostream>
    #include <string>
    using namespace std;
    
    int main() {
        int n;
        cin >> n;
        int cards[4][13] = {0};
        for (int i = 0; i < n; i++) {
            string card;
            cin >> card;
            int suit;
            if (card[0] == 'S') suit = 0;
            else if (card[0] == 'H') suit = 1;
            else if (card[0] == 'C') suit = 2;
            else suit = 3;
            int rank;
            if (card[1] == 'A') rank = 0;
            else if (card[1] == '2') rank = 1;
            else if (card[1] == '3') rank = 2;
            else if (card[1] == '4') rank = 3;
            else if (card[1] == '5') rank = 4;
            else if (card[1] == '6') rank = 5;
            else if (card[1] == '7') rank = 6;
            else if (card[1] == '8') rank = 7;
            else if (card[1] == '9') rank = 8;
            else if (card[1] == 'T') rank = 9;
            else if (card[1] == 'J') rank = 10;
            else if (card[1] == 'Q') rank = 11;
            else if (card[1] == 'K') rank = 12;
            cards[suit][rank]++;
        }
        int missing = 0;
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 13; j++) {
                if (cards[i][j] == 0) {
                    missing++;
                }
            }
        }
        cout << missing << endl;
        return 0;
    }
    

    信息

    ID
    2161
    时间
    1000ms
    内存
    256MiB
    难度
    6
    标签
    递交数
    26
    已通过
    12
    上传者