#include#include #include #include #define NUM_SUITS 4 #define NUM_RANKS 13 int main(void) { bool in_hand[NUM_SUITS][NUM_RANKS] = { false }; int num_cards, rank, suit; const char* rank_code[13] = { "two","three","four","five","six","seven","eight", "nine","ten","Jack","Queen","King","Ace" }; const char* suit_code[4] = { "Spade","Heart","Diamond","Club" }; srand((unsigned)time(NULL)); printf("Enter number of cards in hand: "); scanf_s("%d", &num_cards); printf("Your hand:n"); while (num_cards > 0) { suit = rand() % NUM_SUITS; rank = rand() % NUM_RANKS; if (in_hand[suit][rank] == false) { in_hand[suit][rank] = true; num_cards--; printf("%s of %sn", rank_code[rank], suit_code[suit]); } } return 0; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)