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
|
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
/*ranks: A, 2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K
suits: C, D, H, S*/
string cards[52] = { "CA", "C2", "C3","C4", "C5","C6","C7","C8","C9","CT","CJ","CQ","CK",
"DA", "D2", "D3","D4", "D5","D6","D7","D8","D9","DT","DJ","DQ","DK",
"HA", "H2", "H3","H4", "H5","H6","H7","H8","H9","HT","HJ","HQ","HK",
"SA", "S2", "S3","S4", "S5","S6","S7","S8","S9","ST","SJ","SQ","SK" };
int card, num;
for (int original = 0; original<52; original++) {
cin >> card;
int again = card % 52;
swap(cards[original], cards[again]);
}
for (auto card : cards)
std::cout << card << ' ';
// or:
std::cout << '\n';
for (std::size_t i = 0; i < 52; ++i)
std::cout << cards[i] << ' ';
}
|