Wu shi king
unknown
c_cpp
8 months ago
1.3 kB
3
Indexable
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
using namespace std;
// Function to create a deck of 54 cards
vector<string> createDeck() {
vector<string> deck;
vector<string> suits = {"♥", "♦", "♣", "♠"};
vector<string> ranks = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};
// Add the 52 standard cards
for (const string& suit : suits) {
for (const string& rank : ranks) {
deck.push_back(rank + suit);
}
}
// Add the two Jokers
deck.push_back("Red Joker 🃏");
deck.push_back("Black Joker 🃏");
return deck;
}
// Function to shuffle the deck
void shuffleDeck(vector<string>& deck) {
random_device rd;
mt19937 g(rd());
shuffle(deck.begin(), deck.end(), g);
}
// Function to display the deck
void displayDeck(const vector<string>& deck) {
for (const string& card : deck) {
cout << card << " ";
}
cout << endl;
}
int main() {
// Create the deck
vector<string> deck = createDeck();
// Display the original deck
cout << "Original Deck:\n";
displayDeck(deck);
// Shuffle the deck
shuffleDeck(deck);
cout << "\nShuffled Deck:\n";
displayDeck(deck);
return 0;
}Editor is loading...
Leave a Comment