#include <iostream>
using namespace std;
const int N = 54;
char mp[5] = {'S', 'H', 'C', 'D', 'J'};
int start[N+1], end[N+1], next[N+1];
int main(){
int i = 1, K;
cin >> K;
while(i++ < N){
start[i] = i;// 初始化牌的编号
}
i = 0;
while(i++ < N){
cin >> next[i];
}
int step = 0;
i = 0;
while(step++ < K){
while(i++ < N){
end[next[i]] = start[i];
}
i = 0;
while(i++ < N){
start[i] = end[i];
}
}
i = 0;
while(i++ < N){
if(i != 1){
cout << ' ';// 添加空格
}
start[i]--;
cout << mp(start[i] / 13) << start[i] % 13 + 1;
}
return 0;
}
这道题的思路,还蛮简单的,三个数组,来回倒腾就可以了,start,end,next数组,start数组存放初始编号,next数组存放洗牌一次后当前牌所在的位置,最后start等于end,输出start中的数据即可
注意对start中的元素转为牌号时,需要减一,小细节