Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. char *values[13]= {
  5.     "ace", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "Jack", "Queen", "King"
  6. };
  7.  
  8. struct Card {
  9.     int suit;
  10.     int value;
  11.     char values[10];
  12. };
  13.  
  14. void fillDeck(struct Card deck [52]) {
  15.     int count = 0;
  16.     for (int h = 0; h <4;h++)
  17.         for (int i = 0; i < 13;i++, count++){
  18.             deck[count].suit = h;
  19.             deck[count].value=i;
  20.             strcpy(deck[count].values, values[i]);
  21.         }
  22. }
  23.  
  24. void printDeck(struct Card deck [52]) {
  25.     for (int i = 0;i<52;i++){
  26.         printf("%d - %s\n", deck[i].suit, deck[i].values[i]);
  27.     }
  28. }
  29.  
  30.  
  31.  
  32.  
  33. int main(){
  34.     struct Card deck[52];
  35.     fillDeck(deck);
  36.     printDeck(deck);
  37.  
  38.    
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement