发纸牌c语⾔编程,C语⾔--扑克牌⽣成程序// poker.c
// day05
//
// ⼀个扑克牌⽣成程序:运⾏如下:
// 请输⼊你要的张数:5编程语言下载
// 程序输出:H5、H6、H7、H8、H9(Spade(⿊桃)、Club(梅花)、Heart(红桃)、Diamond(⽅块))
// 建议:char suit[4] = {'S','D','C','H'}
// char rank[13] = {'2','3','4','5','6','7','8','9','T','J','Q','K','A'};
// Created by apple on 13-6-6.
// Copyright (c) 2013年 apple. All rights reserved.
//
#include
#include
#include
int main()
{
char suit[4] = {'S','C','H','D'};
char rank[13] = {'2','3','4','5','6','7','8','9','T','J','Q','K','A'};
int num = 0,a = 0,b = 0;
int temp[4][13] = {0};
srand((unsigned)time(0));
printf("请输⼊您要的张数:");
scanf("%d",&num);
a = rand() % 4;
b = rand() % 13;
do{
if(temp[a][b]==1){
a = rand() % 4;
b = rand() % 13;
}else{
printf("%c%c\t",suit[a],rank[b]);
temp[a][b] = 1;
num--;
}
}while(num); return 0;
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。