重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
本篇文章为大家展示了使用C语言编写一个洗牌与发牌游戏,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
在坪山等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供网站建设、网站设计 网站设计制作定制网站,公司网站建设,企业网站建设,品牌网站建设,成都营销网站建设,成都外贸网站建设公司,坪山网站建设费用合理。普通版
#include#include #include #define SUITS 4 #define FACES 13 #define CARDS 52 void shuffle(int wDeck[][FACES]); void send(int wDeck[][FACES], const char* wSuit[], const char* wFace[]); void main() { int deck[SUITS][FACES]={0}; const char* suit[SUITS]={"Heart","Diamond","Club","Spade"}; const char* face[FACES]={"Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"}; srand(time(NULL)); shuffle(deck); send(deck, suit, face); } void shuffle(int wDeck[][FACES]) { int row,column,card; for(card=1;card<=CARDS;card++) { row = rand() % SUITS; column = rand() % FACES; while(wDeck[row][column] != 0) { row = rand() % SUITS; column = rand() % FACES; } wDeck[row][column] = card; } } void send(int wDeck[][FACES], const char* wSuit[], const char* wFace[]) { int card,row,column; for(card=1;card<=CARDS;card++) { for(row=0;row 高性能版
//先按顺序填满52个格子,再产生随机格子相互交换 #include#include #include #define CARDS 52 #define FACES 13 struct card { const char* face; const char* suit; }; typedef struct card Card; void shuffle(Card *const wDeck); void send(const Card *const wDeck);//指针常量与数据常量均不可以改变,都用const限定,*前是限定指针,*后是限定数据 void main() { const char* wSuit[]={"Heart","Diamond","Club","Spade"};//指针数组是一个数组 const char* wFace[]={"Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"}; int i; Card deck[CARDS]; for(i=0;i 上述内容就是使用C语言编写一个洗牌与发牌游戏,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注创新互联行业资讯频道。
文章题目:使用C语言编写一个洗牌与发牌游戏-创新互联
本文链接:http://cqcxhl.cn/article/jojsh.html