• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Dec 8th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. void Deck_Creator(cards* deck) {            // od 5 do 13 == od 20 do 52
2.     for (int i = 0; i < SIZE; i++) {
3.         deck[i].suit = (Suit)(i % 4);
4.         deck[i].power = (Power)(i % 13);
5.     }
6.
7. }
8.
9. void Display_Deck(cards* deck) {
10.     for (int i = 0; i < SIZE; i++) {
11.
12.         if (deck[i].suit == Diamonds) {
13.             cout << "Diamond ";
14.         }
15.         else if (deck[i].suit == Hearts) {
16.             cout << "Heart ";
17.         }
18.         else if (deck[i].suit == Spades) {
20.         }
21.         else if (deck[i].suit == Clubs) {
22.             cout << "Club ";
23.         }
24.         //if (deck[i].power >= 3) {
25.             cout << " " << deck[i].power << " | ";
26.         //}
27.         //else cout
28.     }
29. }
30.
31. void Deck_Shuffler(cards* deck) {
32.     int changer = 0;               // Index of changed card
33.     cards temp = {};             // Temporary holding place for changing
34.     srand(time(NULL));            // Function to get random numbers with current time
35.     for (int i = 0; i < SIZE; i++) {
36.         changer = rand() % SIZE;   // Generating random number from 0 to 51
37.         temp = deck[i];
38.         deck[i] = deck[changer];  // if changer = i
39.         deck[changer] = temp;
40.     }
41. }
42.
43. void Deck1_Creator(cards* deck1, cards* deck, decks* q_deck1) {
44.     for (int i = 0; i < HALF_SIZE; i++) {
45.         memcpy(&deck1[i], &deck[i], sizeof(cards));  // Copying content using memcpy function
46.     }
47.     q_deck1->p_deck = deck1;
48.     q_deck1->size = HALF_SIZE;
49. }
50.
51. void Deck2_Creator(cards* deck, cards* deck2, decks* q_deck2) {
52.     int i = HALF_SIZE;
53.     for (int i = 26; i < SIZE; i++) {
54.         deck2[i - HALF_SIZE] = deck[i];   // Simple copying struct array content into another array
55.     }
56.     q_deck2->p_deck = deck2;
57.     q_deck2->size = HALF_SIZE;
58. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top