Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.66 KB | None | 0 0
  1. #include "poker.h"
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. int main () {
  6.     srand(time(NULL));
  7.     CARTA **mazzo = crea_mazzo();
  8.     CARTA *singola = estrai_carta(mazzo);
  9.     printf("VALORE: %d ; SEME: %d ; COLORE: %d\n", singola->v, singola->c, singola->s);
  10.     return EXIT_SUCCESS;
  11. }
  12.  
  13. CARTA **crea_mazzo () {
  14.     CARTA **mazzo = malloc(sizeof(CARTA*));
  15.     int i;
  16.     for (i=0; i < 52; i++) {
  17.         CARTA *singola = malloc(sizeof(CARTA));
  18.         singola->v = (rand() % 13);
  19.         singola->c = (rand() % 2);
  20.         singola->s = (rand() % 4);
  21.         mazzo[i] = singola;
  22.     }
  23.     return mazzo;
  24. }
  25.  
  26. CARTA *estrai_carta (CARTA ***mazzo) {
  27.     CARTA *singola;
  28.     singola = mazzo[rand() % 52];
  29.     return singola;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement