`
风吹过PP好冷
  • 浏览: 36659 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

PAT1042 Shuffling Machine

    博客分类:
  • PAT
 
阅读更多

扑克洗牌

 

 

 

#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <algorithm>
using namespace std;

void Createpoker(vector<string> &poker, string s)
{
    for (int i = 1; i < 14; i++)
    {
        if (i > 9)
        {
            string str = s + "1";
            char c = i%10 + '0';
            str = str + c;
            poker.push_back(str);
        }
        else
        {
            string str = s;
            char c = i + '0';
            str = str + c;
            poker.push_back(str);
        }
    }
}

int main()
{
    vector<string> poker;
    Createpoker(poker, "S");
    Createpoker(poker, "H");
    Createpoker(poker, "C");
    Createpoker(poker, "D");
    poker.push_back("J1");
    poker.push_back("J2");

    int K;
    cin>>K;
    vector<int> sortnum;
    int m = 54;
    while(m--)
    {
        int x;
        cin>>x;
        sortnum.push_back(x - 1);
    }

    vector<string> result(54,"");

    while(K--)
    {

        for (int i = 0; i < 54; i++)
        {
            result[sortnum[i]] = poker[i]; 
        }
        poker.clear();
        poker.insert(poker.end(),result.begin(),result.end());
    }

    for (int i = 0; i < 53; i++)
    {
        cout<<result[i]<<" ";
    }
    cout<<result[53];

    return 0;
}

 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics