#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define CARDS 52
#define DRAW 5
void showcard(int card);
int main() {
int deck[CARDS];
int c;
/* initialize the deck */
for (int x = 0; x < CARDS; x++) deck[x] = 0;
for (int x = 0; x < DRAW; x++) {
for(;;) { /* loop until a valid card is drawn */
c
= rand() % CARDS
; /* generate random drawn */ if(deck[c] == 0) { /* has card been drawn? */
deck[c] = 1; /* show that card is drawn */
showcard(c); /* display card */
break; /* end the loop */
}
} /* repeat loop until valid card found */
}
}
void showcard(int card) {
char *suit[4] = { "Spades", "Hearts", "Clubs", "Diamonds" };
switch (card % 13) {
case 0:
break;
case 10:
break;
case 11:
break;
case 12:
break;
default:
}
printf(" of %s\n",suit
[card
/13]); }
//https://pt.stackoverflow.com/q/41829/101
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHRpbWUuaD4KCiNkZWZpbmUgQ0FSRFMgNTIKI2RlZmluZSBEUkFXIDUKCnZvaWQgc2hvd2NhcmQoaW50IGNhcmQpOwoKaW50IG1haW4oKSB7CiAgICBpbnQgZGVja1tDQVJEU107CiAgICBpbnQgYzsKCi8qIGluaXRpYWxpemUgdGhlIGRlY2sgKi8KICAgIGZvciAoaW50IHggPSAwOyB4IDwgQ0FSRFM7IHgrKykgZGVja1t4XSA9IDA7CiAgICBzcmFuZCgodW5zaWduZWQpdGltZShOVUxMKSk7CiAgICBmb3IgKGludCB4ID0gMDsgeCA8IERSQVc7IHgrKykgewogICAgICAgIGZvcig7OykgeyAgICAgICAgICAgICAgICAgLyogbG9vcCB1bnRpbCBhIHZhbGlkIGNhcmQgaXMgZHJhd24gKi8KICAgICAgICAgICAgYyA9IHJhbmQoKSAlIENBUkRTOyAgICAgLyogZ2VuZXJhdGUgcmFuZG9tIGRyYXduICovCiAgICAgICAgICAgIGlmKGRlY2tbY10gPT0gMCkgeyAgICAgICAvKiBoYXMgY2FyZCBiZWVuIGRyYXduPyAqLwogICAgICAgICAgICAgICAgZGVja1tjXSA9IDE7ICAgICAgICAvKiBzaG93IHRoYXQgY2FyZCBpcyBkcmF3biAqLwogICAgICAgICAgICAgICAgc2hvd2NhcmQoYyk7ICAgICAgICAvKiBkaXNwbGF5IGNhcmQgKi8KICAgICAgICAgICAgICAgIGJyZWFrOyAgICAgICAgICAgICAgLyogZW5kIHRoZSBsb29wICovCiAgICAgICAgICAgIH0KICAgICAgICB9ICAgICAgICAgICAgICAgICAgICAgICAvKiByZXBlYXQgbG9vcCB1bnRpbCB2YWxpZCBjYXJkIGZvdW5kICovCiAgICB9Cn0KCnZvaWQgc2hvd2NhcmQoaW50IGNhcmQpIHsKICAgIGNoYXIgKnN1aXRbNF0gPSB7ICJTcGFkZXMiLCAiSGVhcnRzIiwgIkNsdWJzIiwgIkRpYW1vbmRzIiB9OwogICAgc3dpdGNoIChjYXJkICUgMTMpIHsKICAgICAgICBjYXNlIDA6CiAgICAgICAgICAgIHByaW50ZigiJTJzIiwiQSIpOwogICAgICAgICAgICBicmVhazsKICAgICAgICBjYXNlIDEwOgogICAgICAgICAgICBwcmludGYoIiUycyIsIkoiKTsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgY2FzZSAxMToKICAgICAgICAgICAgcHJpbnRmKCIlMnMiLCJRIik7CiAgICAgICAgICAgIGJyZWFrOwogICAgICAgIGNhc2UgMTI6CiAgICAgICAgICAgIHByaW50ZigiJTJzIiwiSyIpOwogICAgICAgICAgICBicmVhazsKICAgICAgICBkZWZhdWx0OgogICAgICAgICAgICBwcmludGYoIiUyZCIsY2FyZCUxMysxKTsKICAgIH0KICAgIHByaW50ZigiIG9mICVzXG4iLHN1aXRbY2FyZC8xM10pOwp9CgovL2h0dHBzOi8vcHQuc3RhY2tvdmVyZmxvdy5jb20vcS80MTgyOS8xMDE=