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