Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- // functions
- void listCards();
- void randomHand(int numberOfCards);
- // cards array
- char *Spades[13] = {
- "๐ก", "๐ข",
- "๐ฃ", "๐ค",
- "๐ฅ", "๐ฆ",
- "๐ง", "๐จ",
- "๐ฉ", "๐ช",
- "๐ซ", "๐ญ",
- "๐ฎ",
- };
- char *Hearts[13] = {
- "๐ฑ", "๐ฒ",
- "๐ณ", "๐ด",
- "๐ต", "๐ถ",
- "๐ท", "๐ธ",
- "๐น", "๐บ",
- "๐ป", "๐ฝ",
- "๐พ"
- };
- char *Diamonds[13] = {
- "๐", "๐",
- "๐", "๐",
- "๐ ", "๐",
- "๐", "๐",
- "๐", "๐",
- "๐", "๐",
- "๐",
- };
- char *Clubs[13] = {
- "๐", "๐",
- "๐", "๐",
- "๐", "๐",
- "๐", "๐",
- "๐", "๐",
- "๐", "๐",
- "๐",
- };
- char *Deck[52] = {
- "๐ก", "๐ข",
- "๐ฃ", "๐ค",
- "๐ฅ", "๐ฆ",
- "๐ง", "๐จ",
- "๐ฉ", "๐ช",
- "๐ซ", "๐ญ",
- "๐ฑ", "๐ฒ",
- "๐ณ", "๐ด",
- "๐ต", "๐ถ",
- "๐ท", "๐ธ",
- "๐น", "๐บ",
- "๐ป", "๐ฝ",
- "๐พ", "๐",
- "๐", "๐",
- "๐ ", "๐",
- "๐", "๐",
- "๐", "๐",
- "๐", "๐",
- "๐", "๐",
- "๐", "๐",
- "๐", "๐",
- "๐", "๐",
- "๐", "๐",
- "๐", "๐",
- "๐", "๐ฎ",
- "๐", "๐"
- };
- int main (int argc, char **argv) {
- time_t t;
- srand((unsigned)time(&t));
- if (argc < 2) {
- printf("\nThis program will generate a field of cards.\commands:\nlist - lists all 52 cards in a deck\n");
- return 0;
- }
- if (strcmp(argv[1], "list") == 0)
- listCards();
- if (strcmp(argv[1], "hand") == 0)
- randomHand(atoi(argv[2]));
- return 0;
- }
- void listCards() {
- int x = 0;
- for (x; x < 13; x++) {
- printf("%s", Spades[x]);
- printf("%s", Hearts[x]);
- printf("%s", Diamonds[x]);
- printf("%s\n", Clubs[x]);
- }
- }
- void randomHand(int numberOfCards) {
- int x = 0;
- for (x; x < numberOfCards; x++) {
- printf("%s", Deck[rand() % 52]);
- }
- printf("\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement