Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #define COLOR_SIZE 5
- //visual studio compatibility
- #ifdef _MSC_VER
- #define _CRT_SECURE_NO_DEPRECATE
- #pragma warning (disable : 4996)
- #endif
- //struktura talii jako lista
- typedef struct deck {
- int card_value;
- char znak[6];
- struct deck* next;
- }deck_t;
- //znaki do inicjalizacji w funkcjach
- char pik[4] = "PIK";
- char kier[5] = "KIER";
- char trefl[6] = "TREFL";
- char karo[5] = "KARO";
- //inicjalizacja talii kart
- void init_deck(deck_t *deck)
- {
- deck->next = NULL;
- }
- //wypelnienie talii kart
- void create_deck(deck_t* deck,int value,int znak)
- {
- deck_t* x = (deck_t*)malloc(sizeof(deck_t));
- x->card_value = value;
- if (znak == 0)
- {
- strncpy (x->znak, pik , 4);
- x->znak[3] = '\0';
- }
- else if (znak == 1)
- {
- strncpy(x->znak, kier, 5);
- x->znak[4] = '\0';
- }
- else if (znak == 2)
- {
- strncpy(x->znak, trefl, 6);
- x->znak[5] = '\0';
- }
- else if (znak == 3)
- {
- strncpy(x->znak, karo, 5);
- x->znak[4] = '\0';
- }
- x->next = deck->next;
- deck->next = x;
- }
- //losowanie rÄ…k graczy
- void create_hand(deck_t*hand_x,deck_t*hand_y,deck_t*deck)
- {
- }
- /*void print(deck_t* deck)
- {
- deck = deck->next;
- while (deck != NULL)
- {
- std::cout << deck->card_value << " " << deck->znak << std::endl;
- deck = deck->next;
- }
- }*/
- int main()
- {
- deck_t deck[COLOR_SIZE * 4];
- deck_t* cur = &deck;
- for (int j = 0; j < 4; j++)
- {
- for (int i = 14; i > 14 - COLOR_SIZE; i--)
- {
- create_deck(cur, i, j);
- cur = cur->next;
- }
- }
- deck_t* hand_x = (deck_t*)malloc(sizeof(deck_t));
- deck_t* hand_y = (deck_t*)malloc(sizeof(deck_t));
- if (hand_x == NULL||hand_y==NULL)
- std::cout << "Blad przy alokacji pamieci!" << std::endl;
- else
- {
- std::cout << cur->card_value;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement