1042 Shuffling Machine (20分)

1. 题目

2. 思路

常规题目

3. 注意点

4. 代码

#include<cstdio>
#include<vector>
#include<string>

using namespace std;

int n;
int order[55];
vector<string> cards;

void init_cares(){
    cards.push_back(""); //占位
    for(int i=1;i<=13;i++){
        cards.push_back("S"+to_string(i));
    }
    for(int i=1;i<=13;i++){
        cards.push_back("H"+to_string(i));
    }
    for(int i=1;i<=13;i++){
        cards.push_back("C"+to_string(i));
    }
    for(int i=1;i<=13;i++){
        cards.push_back("D"+to_string(i));
    }
    cards.push_back("J1");
    cards.push_back("J2");
}

void shuffling(){
    vector<string> temp(55, "");
    for(int i=1;i<=54;i++){
        temp[order[i]] = cards[i];
    }
    cards = temp;
}

int main(){
    init_cares();
    scanf("%d", &n);
    for(int i=1;i<=54;i++){
        scanf("%d", &order[i]);
    }
    for(int i=0;i<n;i++){
        shuffling();
    }
    for(int i=1;i<54;i++){
        printf("%s ", cards[i].c_str());
    }
    printf("%s", cards[54].c_str());
}

原文地址:https://www.cnblogs.com/d-i-p/p/12411953.html

时间: 2024-10-02 18:41:38

1042 Shuffling Machine (20分)的相关文章

【PAT甲级】1042 Shuffling Machine (20 分)

题意: 输入洗牌次数K(<=20),输入54张牌每次洗入的位置(不是交换的位置),输出洗好的牌. 代码: #define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;multiset<int>st;int a[57];int card[57],b[57];int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

PAT 1042. Shuffling Machine (20)

1042. Shuffling Machine (20) Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "inside jobs" where employees collaborate with gamblers by performing

1042. Shuffling Machine (20)

Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "inside jobs" where employees collaborate with gamblers by performing inadequate shuffles, many cas

1042. Shuffling Machine (20) - sstream实现数字转字符串

题目如下: Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "inside jobs" where employees collaborate with gamblers by performing inadequate shuffles, ma

PAT(A) 1042. Shuffling Machine (20)

The machine shuffles a deck of 54 cards according to a given random order and repeats for a given number of times. It is assumed that the initial status of a card deck is in the following order: S1, S2, ..., S13, H1, H2, ..., H13, C1, C2, ..., C13, D

PAT甲题题解-1042. Shuffling Machine (20)-模拟

博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789205.html特别不喜欢那些随便转载别人的原创文章又不给出链接的所以不准偷偷复制博主的博客噢~ 给出洗牌次数,以及洗牌的序列规则第i个数shuffles[i]表示要将第i张牌移到第shuffles[i]个 很简单,就是shuffle_seq[shuffles[i]]=start_seq[i]; #include <iostream> #include

PAT:1042. Shuffling Machine (20) AC

#include<stdio.h> #include<stdlib.h> const int N=54; int main() { char mp[5]={'S','H','C','D','J'}; int n; scanf("%d",&n); int start[N],end[N],next[N]; for(int i=1 ; i<=N ; ++i) //初始化 start[i]=i; for(int i=1 ; i<=N ; ++i) /

PAT (Advanced Level) 1042. Shuffling Machine (20)

简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<queue> #include<stack> #include<string> #include<algorithm> using namespace std; struct X { char c; int n

1042. Shuffling Machine

1042. Shuffling Machine (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "inside