13---3

13---3,第1张

13---3
#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;
}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5690805.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存