原题链接:https://www.nowcoder.com/pat/5/problem/4081
#pragma warning(disable:4996)
#include<iostream>
#include<vector>
// 简单总结:
// 1)这里如果shuffle_time非常大 vector产生的辅助空间可能非常大
// 好像两个数组就行了,不用vector容器类 不过这个写习惯了
// 可以循环覆盖vector card[i][0]和vector card[i][1] 节省空间
// 2) 后面5段printf 有点蠢,可以创建一个char s[5]={'H','S','C','D','J'}
// 输出时,s[值/13]即可获取相应花色
using namespace std;
int shuffle_time;
int order[54];
vector<int> card[55];
void shuffle(int times) {
for (int i = 0; i < times; i++) {
for (int j = 0; j < 54; j++) {
card[order[j]].push_back(card[j+1][i]);
}
}
}
int main() {
cin >> shuffle_time;
for (int i = 0; i < 54; i++) {
cin>>order[i];
card[i+1].push_back(i+1);
}
shuffle(shuffle_time);
for (int i = 1; i < 55; i++) {
if (card[i][shuffle_time] < 14) {
printf("S%d ", card[i][shuffle_time]);
}
else if (card[i][shuffle_time] < 27) {
printf("H%d ", card[i][shuffle_time]-13);
}
else if (card[i][shuffle_time] < 40) {
printf("C%d ", card[i][shuffle_time]-26);
}
else if (card[i][shuffle_time] < 53) {
printf("D%d ", card[i][shuffle_time]-39);
}
else if (card[i][shuffle_time] <56) {
printf("J%d ", card[i][shuffle_time]-52);
}
}
system("pause");
return 0;
}