当前位置:网站首页>Basic methods of realizing licensing function in C language
Basic methods of realizing licensing function in C language
2022-07-26 05:16:00 【an520_】
Hello everyone !
Today I would like to talk with you , How to use it C Language implementation of automatic licensing program .
First of all : Problem description
A deck of poker has 52 card , When you play bridge, you should give the cards to 4 personal . Please design a program to complete the automatic licensing work . requirement : For spades S (Spaces) Express , For hearts H (Hearts) Express , Square with D (Diamonds) Express , Plum blossom with C (Clubs) Express .
second : Problem analysis
Ideas :
This problem is relatively simple to realize , Just define two multidimensional character arrays , The first number used to store poker , The second is for storing 4 A player's hand .
52 A card is given to 4 personal , Need to send 13 round , Each round deals cards to players in the order of their numbers , When licensing , Generate the number to be dealt with a random function ( For the introduction of random functions, please refer to my chapter 61 Days of practice ), If the card has not been issued before ( The issued cards are used for '\0' Mark ), Then the card number is stored in the player's hand array , At the same time, assign the number of the card to '\0'. If the card corresponding to the generated random number has been dealt , Then continue to generate new random numbers . When 52 All cards have been issued , Print the result of the deal .
Poker array char poker[4][13]; Medium 4 There are four kinds of designs and colors ,13 Indicates that each has 13 Zhang (13 Number ), The number of playing cards ( name ) To express in characters , Respectively :{'2', '3', '4', '5', '6', '7', '8', '9', '0', 'J', 'Q', 'K', 'A'}('0' Express 10)
The player's hand array is a three-dimensional character array ,char players[PLAYER_NUMBER][4][13] = {0}; (PLAYER_NUMBER It's the number of players ,4 The colors and types of the sign are 4 Kind of ,13 The most cards for a suit 13 Zhang )
On initialization , All values of the hand array are set to '\0', No card on hand .
Third : Code implementation




Fourth : Running results

summary : Only practice more , In the process of practicing , Find the problem points, solve them one by one and summarize , To go further .
【 Learning exchange group 769843038】
【 Share some tutorial materials below 】:
C The language expression program is written like this ,99.9% To succeed !
C The link list of basic language tutorials
c Automatic language compilation , Effectively improve your development efficiency !
1 Hours to get you started Linux Next C Language development
c Code debugging is more efficient in this way
C Fundamentals of language programming
【 Free information package on the net disk below , Rest assured to receive what you need 】:
Embedded Internet of things stm32 c/c++、QT Linux Data package 【 Huaqing vision issued the information package 】
http://makerschool.mikecrm.com/7ADq4jq

边栏推荐
- 基于R语言的Meta分析【全流程、不确定性分析】方法与Meta机器学习
- Yolov5 implementation process - Directory
- 面试之请详细说下synchronized的实现原理以及相关的锁
- NetCore MySql The user specified as a definer (‘admin‘@‘%‘) does not exist
- 【Leetcode】493. Reverse Pairs
- Mysql优化
- An online accident, I suddenly realized the essence of asynchrony
- Nacos registry
- nacos注册中心
- ABAP语法学习(ALV)
猜你喜欢
随机推荐
Improve reduce parallelism in shuffle operation
Embedded sharing collection 20
Webassembly 01 basic information
SQL注入
35. 搜索插入位置
MySQL basic learning
基于遥感解译与GIS技术环境影响评价图件制作
Leetcode linked list problem - 203. remove the linked list elements (learn the linked list by one question and one article)
【pytorch】torch1.8.1安装、查看torch版本、GPU是否可用
Nacos registry
Mysql优化
Okaleido上线聚变Mining模式,OKA通证当下产出的唯一方式
Shell流程控制(重点)、if 判断、case 语句、let用法、for 循环中有for (( 初始值;循环控制条件;变量变化 ))和for 变量 in 值 1 值 2 值 3… 、while 循环
Your understanding of the "happen before principle" may be wrong?
MySQL eight knowledge points: from getting started to deleting the database
LeetCode链表问题——203.移除链表元素(一题一文学会链表)
攻防世界-FlatScience
新导则下的防洪评价报告编制方法及洪水建模
Please elaborate on the implementation principle of synchronized and related locks
CMD操作命令









