# ZeroJudge - f647: 撲克牌
### 題目連結:https://zerojudge.tw/ShowProblem?problemid=f647
###### tags: `ZeroJudge` `模擬`
```cpp=
#include <iostream>
#include <string>
using namespace std;
string poker[53] = {
"XX",
"SA", "S2", "S3", "S4", "S5", "S6", "S7", "S8", "S9", "S10", "SJ", "SQ", "SK",
"HA", "H2", "H3", "H4", "H5", "H6", "H7", "H8", "H9", "H10", "HJ", "HQ", "HK",
"DA", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "D9", "D10", "DJ", "DQ", "DK",
"FA", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "FJ", "FQ", "FK"
};
int deck[53] = {
0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52
}, swapping[53];
void MoveNToPlace(int lower, int upper, int position) {
if (position == lower)
return;
for (int i = position; i <= position + upper - lower; ++i)
swapping[i] = deck[i - position + lower];
for (int i = position + upper - lower + 1; i <= upper; ++i)
swapping[i] = deck[i - upper + lower - 1];
for (int i = position; i <= upper; ++i)
deck[i] = swapping[i];
}
int main() {
cin.sync_with_stdio(false); cin.tie(nullptr);
int commands, command, buffer1, buffer2;
cin >> commands;
while (commands--) {
cin >> command;
switch (command)
{
case 1:
cin >> buffer1 >> buffer2;
MoveNToPlace(buffer1, buffer2, 1);
break;
case 2:
cin >> buffer1 >> buffer2;
MoveNToPlace(buffer2 + 1, 52, buffer1);
break;
case 3:
cin >> buffer1;
MoveNToPlace(52 - buffer1 + 1, 52, 1);
break;
default:
cin >> buffer1;
MoveNToPlace(buffer1 + 1, 52, 1);
}
}
for (int i = 1; i <= 5; ++i)
cout << poker[deck[i]] << ' ';
cout << '\n';
}
```