zoukankan      html  css  js  c++  java
  • 占卜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 }
  • 相关阅读:
    服务返返回状态码详解
    LeetCode#28 Implement strStr()
    LeetCode#58 Length of Last Word
    LeetCode#66 Plus One
    spooling技术
    文件的打开与关闭
    DMA方式与通道方式
    中断向量、向量中断、向量地址
    中断响应优先级和中断处理优先级
    I/O接口
  • 原文地址:https://www.cnblogs.com/fx1998/p/13998450.html
Copyright © 2011-2022 走看看