Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "poker.h"
- #include <stdlib.h>
- #include <time.h>
- int main () {
- srand(time(NULL));
- CARTA **mazzo = crea_mazzo();
- CARTA *singola = estrai_carta(mazzo);
- printf("VALORE: %d ; SEME: %d ; COLORE: %d\n", singola->v, singola->c, singola->s);
- return EXIT_SUCCESS;
- }
- CARTA **crea_mazzo () {
- CARTA **mazzo = malloc(sizeof(CARTA*));
- int i;
- for (i=0; i < 52; i++) {
- CARTA *singola = malloc(sizeof(CARTA));
- singola->v = (rand() % 13);
- singola->c = (rand() % 2);
- singola->s = (rand() % 4);
- mazzo[i] = singola;
- }
- return mazzo;
- }
- CARTA *estrai_carta (CARTA ***mazzo) {
- CARTA *singola;
- singola = mazzo[rand() % 52];
- return singola;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement