# 占卜DIY

 1 #include <bits/stdc++.h>
2 using namespace std;
3 const int N = 14;
4 vector<int> cards[N]; //1~13,vector存储初始正面朝下着的牌的情况
5 int open[N]; //正面朝上只需要存储每一堆的个数
6 int get(string c) {
7     if (c[0] == 'A') {
8         return 1;
9     }
10     if (c[0] >= '2' && c[0] <= '9') {
11         return c[0] - '0';
12     }
13     if (c[0] == '0') {
14         return 10;
15     }
16     if (c[0] == 'J') {
17         return 11;
18     }
19     if (c[0] == 'Q') {
20         return 12;
21     }
22     return 13;
23 }
24 int main() {
25     for (int i = 1; i <= 13; i++) {
26         for (int j = 1; j <= 4; j++) {
27             string t;
28             cin >> t;
29             cards[i].push_back(get(t)); //每堆下标为0的是从上往下的第一张
30         }
31     }
32     for (int i = 0; i < 4; i++) { //循环4次
33         int t = cards[13][i]; //取出第13堆的牌，0~4依次是从上往下第1~4张
34         while (t != 13) {
35             open[t]++; //把抽出的牌放在第t堆上
36             int r = cards[t].back(); //再找到第t堆的最下面一个元素
37             cards[t].pop_back();
38             t = r;
39         }
40     }
41     int res = 0;
42     for (int i = 1; i <= 12; i++) {
43         if (open[i] == 4) {
44             res++;
45         }
46     }
47     cout << res << endl;
48     return 0;
49 }

posted @ 2020-11-18 10:33  kyk333  阅读(137)  评论(0编辑  收藏  举报