• 占卜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 }
  • 相关阅读:
    linux中断申请之request_threaded_irq
    中断处理
    barrier()函数
    Intellij-设置生成serialVersionUID的方法
    mybatis一级缓存二级缓存
    mysql-EXPLAIN
    mybatis配置多个数据源事务(Transaction)处理
    mybatis实战教程三:mybatis和springmvc整合
    责任链模式
    MySQL-InnoDB-锁
  • 原文地址:https://www.cnblogs.com/fx1998/p/13998450.html
Copyright © 2020-2023  润新知