zoukankan      html  css  js  c++  java
  • 【PAT甲级】1042 Shuffling Machine (20 分)

    题意:

    输入洗牌次数K(<=20),输入54张牌每次洗入的位置(不是交换的位置),输出洗好的牌。

    AAAAAccepted code:

     1 #define HAVE_STRUCT_TIMESPEC
     2 #include<bits/stdc++.h>
     3 using namespace std;
     4 multiset<int>st;
     5 int a[57];
     6 int card[57],b[57];
     7 int main(){
     8     ios::sync_with_stdio(false);
     9     cin.tie(NULL);
    10     cout.tie(NULL);
    11     for(int i=1;i<=54;++i)
    12         card[i]=i;
    13     int k;
    14     cin>>k;
    15     for(int i=1;i<=54;++i)
    16         cin>>a[i];
    17     for(int i=1;i<=k;++i){
    18         if(i&1)
    19             for(int j=1;j<=54;++j)
    20                 b[a[j]]=card[j];
    21         else
    22             for(int j=1;j<=54;++j)
    23                 card[a[j]]=b[j];
    24     }
    25     int x=0;
    26     for(int i=1;i<=54;++i){
    27         if(k&1)
    28             x=b[i];
    29         else
    30             x=card[i];
    31         if(x<=13)
    32             cout<<"S"<<x;
    33         else if(x<=26)
    34             cout<<"H"<<x-13;
    35         else if(x<=39)
    36             cout<<"C"<<x-26;
    37         else if(x<=52)
    38             cout<<"D"<<x-39;
    39         else
    40             cout<<"J"<<x-52;
    41         if(i<54)
    42             cout<<" ";
    43     }
    44     return 0;
    45 }
    保持热爱 不懈努力 不试试看怎么知道会失败呢(划掉) 世上无难事 只要肯放弃(划掉)
  • 相关阅读:
    #include <boost/shared_array.hpp>
    #include <boost/shared_ptr.hpp>
    #include <boost/scoped_array.hpp>
    df命令
    telnet命令
    sort 命令
    苏宁大数据面试题
    hive严格模式
    k-means伪代码
    vim编辑器
  • 原文地址:https://www.cnblogs.com/ldudxy/p/11588634.html
Copyright © 2011-2022 走看看