# 扑克牌的点数和花色的计算的问题，运用数据结构，C语言的方式怎么做的？

Problem Description`Beggar My Neighbour'' (sometimes known as`

Strip Jack Naked'') is a traditional card game, designed to help teach beginners something about cards and their values. A standard deck is shuffled and dealt face down to the two players, the first card to the non-dealer, the second to the dealer, and so on until each player has 26 cards. The dealer receives the last card. The non-dealer starts the game by playing the top card of her deck (the second last card dealt) face up on the table. The dealer then covers it by playing her top card face up. Play continues in this fashion until a `face'' card (Ace, King, Queen or Jack) is played. The next player must then`

cover'' that card, by playing one card for a Jack, two for a Queen, three for a King and four for an Ace. If a face card is played at any stage during this sequence, play switches and the other player must cover that card. When this sequence has ended, the player who exposed the last face card takes the entire heap, placing it face down under her existing deck. She then starts the next round by playing one card face up as before, and play continues until one player cannot play when called upon to do so, because they have no more cards.

Write a program that will simulate playing this game. Remember that a standard deck (or pack) of cards contains 52 cards. These are divided into 4 suits--Spades (), Hearts(),Diamonds(), and Clubs ().Within each suit there are 13 cards--Ace (A), 2-9, Ten (T), Jack (J), Queen (Q) and King (K).

Input

Input will consist of a series of decks of cards. Each deck will give the cards in order as they would be dealt (that is in the example deck below, the non-dealer would start the game by playing the H2). Decks will occupy 4 lines with 13 cards on each. The designation of each card will be the suit (S, H, D, C) followed by the rank (A, 2-9, T, J, Q, K). There will be exactly one space between cards. The file will be terminated by a line consisting of a single #.

Output

Output will consist of a series of lines, one for each deck in the input. Each line will consist of the number of the winning player (1 is the dealer, 2 is the first to play) and the number of cards in the winner's hand (ignoring any on the stack), right justified in a field of width 3.

Sample Input

HA H3 H4 CA SK S5 C5 S6 C4 D5 H7 HJ HQ

D4 D7 SJ DT H6 S9 CT HK C8 C9 D6 CJ C6

S8 D8 C2 S2 S3 C7 H5 DJ S4 DQ DK D9 D3

H9 DA SA CK CQ C3 HT SQ H8 S7 ST H2 D2

#

Sample Output

1 44

- 点赞
- 写回答
- 关注问题
- 收藏
- 复制链接分享
- 邀请回答

#### 相关推荐

- 回答 1 已采纳 Problem Description 21 point,also named Black Jack, originated in France,has spread around the world. 21 point, a gambling game played by using poker,is also the only one which is able to win banker by using probability calculation. --- Encyclopedia from good search We define blackjack rules are as follows, which is different from the original rules slightly. cards are as follows: A 2 3 4 5 6 7 8 9 10 J Q K A is as 1 point. JQK are all as 10 points. We assume that the casino prepared a lot of cards,that is, you can assume that the probability of getting each card is the same. There are two players who were banker and Player. They get two cards at first and can see the card each other. Player operates first. Every turn, he can bid or stop bidding. If he bid, he can take a card from the deck. Once the the points are over 21,he will lose at once,which is called "busting", otherwise he will bid until stopping bidding and turn to banker. the rule of banker is the same as the player's. If there is no "busting", the one who have higher points win. If they have the same points,they get the tie. Here is the task,we give you the cards that both people have gotten. please judge whether the Player have more than 50% winning percentage, if yes, output "YES", otherwise output,"NO". Oh, yes, everyone is very smart. Input The first line of the input file contains an integer Test(Test<=100000), which indicates the number of test cases. For each test case, there is a string with four characters. the first and the second char indicate the card of the player.and the others indicate the banker's.(we use ‘T’ instead of '10') Output For each case of data output "YES" or "NO", it indicates whether the Player have more than 50% winning percentage. Sample Input 1 TTT9 Sample Output YES //it's clear that player will not bid, then the blanker has only 2/13 winning percentage.
- 回答 1 已采纳 Problem Description 21 point,also named Black Jack, originated in France,has spread around the world. 21 point, a gambling game played by using poker,is also the only one which is able to win banker by using probability calculation. --- Encyclopedia from good search We define blackjack rules are as follows, which is different from the original rules slightly. cards are as follows: A 2 3 4 5 6 7 8 9 10 J Q K A is as 1 point. JQK are all as 10 points. We assume that the casino prepared a lot of cards,that is, you can assume that the probability of getting each card is the same. There are two players who were banker and Player. They get two cards at first and can see the card each other. Player operates first. Every turn, he can bid or stop bidding. If he bid, he can take a card from the deck. Once the the points are over 21,he will lose at once,which is called "busting", otherwise he will bid until stopping bidding and turn to banker. the rule of banker is the same as the player's. If there is no "busting", the one who have higher points win. If they have the same points,they get the tie. Here is the task,we give you the cards that both people have gotten. please judge whether the Player have more than 50% winning percentage, if yes, output "YES", otherwise output,"NO". Oh, yes, everyone is very smart. Input The first line of the input file contains an integer Test(Test<=100000), which indicates the number of test cases. For each test case, there is a string with four characters. the first and the second char indicate the card of the player.and the others indicate the banker's.(we use ‘T’ instead of '10') Output For each case of data output "YES" or "NO", it indicates whether the Player have more than 50% winning percentage. Sample Input 1 TTT9 Sample Output YES //it's clear that player will not bid, then the blanker has only 2/13 winning percentage.
- 回答 1 已采纳 Problem Description The magician shuffles a small pack of cards, holds it face down and performs the following procedure: 1.The top card is moved to the bottom of the pack. The new top card is dealt face up onto the table. It is the Ace of Spades. 2.Two cards are moved one at a time from the top to the bottom. The next card is dealt face up onto the table. It is the Two of Spades. 3.Three cards are moved one at a time… 4.This goes on until the nth and last card turns out to be the n of Spades. This impressive trick works if the magician knows how to arrange the cards beforehand (and knows how to give a false shuffle). Your program has to determine the initial order of the cards for a given number of cards, 1 ≤ n ≤ 13. Input On the first line of the input is a single positive integer, telling the number of test cases to follow. Each case consists of one line containing the integer n. Output For each test case, output a line with the correct permutation of the values 1 to n, space separated. The first number showing the top card of the pack, etc… Sample Input 2 4 5 Sample Output 2 1 4 3 3 1 4 5 2
- 回答 1 已采纳 Problem Description Bridge is a very complicated card game, and the bidding part is particularly difficult to master. The bidding is made even more difficult because players use different bidding conventions (meanings assigned to bids). In this problem, you are asked to write a program that suggests the first bid that should be made. The bidding conventions described below are simplified from those used by a certain person who shall remain nameless. A bridge hand consists of 13 cards. Each card has a suit (spades, hearts, diamonds, or clubs) and a rank (A, K, Q, J, T, 9, 8, 7, 6, 5, 4, 3, 2). Here, the letter T denotes the card whose rank is 10. Before making a bid, an experienced bridge player studies the number of high card points (hcp) in the hand, as well as the distribution (the number of cards in each suit). The hcp contributed by each card is completely determined by its rank as follows: Rank hcp A 4 K 3 Q 2 J 1 Others 0 For example, if the hand is: Spades: A, 2 Hearts: K, J, T, 9, 2 Diamonds: 3 Clubs: K, Q, 7, 4, 3 Then this hand has 13 hcp and a distribution of 5-5-2-1 (the distribution is usually listed in non-increasing order). A balanced distribution is any one of 4-3-3-3, 4-4-3-2, and 5-3-3-2. In bridge, an opening bid is either "pass" or consists of a level (1-7) and a trump suit. The trump suits are no trump, spades, hearts, diamonds, clubs ranked in decreasing order. Once a hand has been evaluated, the player applies the following list of (simplified) rules to determine the appropriate opening bid. In cases where multiple rules apply, the first one that applies should be used. An "x" in a distribution can be substituted with any non-negative number. Multiple "x"s in a distribution are not necessarily the same. 1. With at least 10 hcp and a y-x-x-x distribution (y >= 8), bid the suit with y cards at the 4 level. This is known as a preemptive bid. 2. With 10-13 hcp and a 7-x-x-x distribution, bid the suit with 7 cards at the 3-level. This is known as a preemptive bid. 3. With 8-9 hcp and a y-x-x-x distribution (y >= 7), bid the suit with y cards at the 2-level if the y-card suit is Spades or Hearts. This is known as a "weak-two" bid. 4. With 8-11 hcp and a 6-x-x-x distribution, in which Spades or Hearts is one of the 6-card suits, bid the higher rank suit at the 2 level. This is known as a "weak-two" bid. 5. With 11-15 hcp, a distribution of 4-4-4-1 or 5-4-4-0, and at least 4 spades, bid Diamonds at the 2 level. This is called the "Mini Roman Convention". 6. With 15-17 hcp and a balanced distribution, bid No Trump at the 1 level provided that at least 3 suits are "stopped." A suit is considered stopped if the suit contains at least one of the following: an A; a K and one other; a Q and two others; or a J and three others; 7. With 20-22 hcp and a balanced distribution, bid No Trump at the 2 level. 8.With at least 22 hcp, bid Clubs at the 2 level. 9. With 13-16 hcp: a. If there is a 5-card or longer suit in Spades or Hearts, bid it at the 1 level. If both bids are possible, bid the longer suit. If both suits have the same length, bid the higher ranking suit. b. Without a 5-card suit in Spades or Hearts, bid the longer of Diamonds or Clubs at the 1 level (whichever one has the most number of cards) . If there is a tie, bid the higher ranking suit. 10. With at least 17 hcp, bid the longest suit at the 1 level. If there is a tie, bid the lowest ranking suit. This is known as a "reverse". 11. If none of the rules above is applicable, bid Pass. In the example above, rule 9a applies and a bid of 1 Hearts should be made. Input The input consists of a number of cases. The bridge hand for each case is specified on one line, with a single space separating each of the 13 cards in the hand. Each card is given as a two-character string. The first letter is the suit (S, H, D, C) and the second character is the rank (A, K, Q, J, T, 9, 8, 7, 6, 5, 4, 3, 2). The end of input is terminated by end-of-file. Output For each case, print the hand number (starting from 1), followed by a colon and a space, and then the suggested bid on a single line (see below for the exact format). Each bid is either "Pass" or a level and a suit ("No Trump", "Spades", "Hearts", "Diamonds", "Clubs") separated by a single space. Sample Input SA S2 HK HJ HT H9 H2 D3 CK CQ C7 C4 C3 SK SQ HT H8 H4 CA CQ CT C5 DK DQ DJ D8 SA SK SQ S3 S2 HT D7 D9 CA CK CQ C7 C5 Sample Output Hand #1: 1 Hearts Hand #2: 1 No Trump Hand #3: 1 Clubs
- 回答 1 已采纳 Problem Description Adam and Eve play a card game using a regular deck of 52 cards. The rules are simple. The players sit on opposite sides of a table, facing each other. Each player gets k cards from the deck and, after looking at them, places the cards face down in a row on the table. Adam’s cards are numbered from 1 to k from his left, and Eve’s cards are numbered 1 to k from her right (so Eve’s i:th card is opposite Adam’s i:th card). The cards are turned face up, and points are awarded as follows (for each i ∈ {1, . . . , k}): If Adam’s i:th card beats Eve’s i:th card, then Adam gets one point. If Eve’s i:th card beats Adam’s i:th card, then Eve gets one point. A card with higher value always beats a card with a lower value: a three beats a two, a four beats a three and a two, etc. An ace beats every card except (possibly) another ace. If the two i:th cards have the same value, then the suit determines who wins: hearts beats all other suits, spades beats all suits except hearts, diamond beats only clubs, and clubs does not beat any suit. For example, the ten of spades beats the ten of diamonds but not the Jack of clubs. This ought to be a game of chance, but lately Eve is winning most of the time, and the reason is that she has started to use marked cards. In other words, she knows which cards Adam has on the table before he turns them face up. Using this information she orders her own cards so that she gets as many points as possible. Your task is to, given Adam’s and Eve’s cards, determine how many points Eve will get if she plays optimally. Input There will be several test cases. The first line of input will contain a single positive integer N giving the number of test cases. After that line follow the test cases. Each test case starts with a line with a single positive integer k <= 26 which is the number of cards each player gets. The next line describes the k cards Adam has placed on the table, left to right. The next line describes the k cards Eve has (but she has not yet placed them on the table). A card is described by two characters, the first one being its value (2, 3, 4, 5, 6, 7, 8 ,9, T, J, Q, K, or A), and the second one being its suit (C, D, S, or H). Cards are separated by white spaces. So if Adam’s cards are the ten of clubs, the two of hearts, and the Jack of diamonds, that could be described by the line TC 2H JD Output For each test case output a single line with the number of points Eve gets if she picks the optimal way to arrange her cards on the table. Sample Input 3 1 JD JH 2 5D TC 4C 5H 3 2H 3H 4H 2D 3D 4D Sample Output 1 1 2
- 回答 3 已采纳 为什么图中最后两个圆柱体积会有偏差![图片](https://img-ask.csdn.net/upload/201703/03/1488537913_161955.jpg)![图片](https://img-ask.csdn.net/upload/201703/03/1488538198_678928.jpg)
- 回答 2 已采纳 Problem Description The game of show hand is a card game. There are 52 cards and each card has a number and a suit. There are 13 different numbers called 2, 3, 4, 5, 6, 7, 8, 9, T (number 10), J (number 11), Q (number 12), K (number 13) and A (number 1 or 14), and there are 4 different suits called diamond (d), club (c), heart (h), and spade (s). A card can be represented as its number and its suit. For example, the card with number 10 and suit diamond is represented as “Td”, where “T” is for number 10 and “d” is for suit diamond. A hand is a combination of 5 cards. There are 9 different kinds of hands, sorted from best to worst, listed below. “Straight Flush”: 5 cards with consecutive numbers and the same suit. For example: Td Jd Qd Kd Ad. “4 of a Kind”: 4 cards with the same number and an arbitrary single card. For example: 2d 2c 2h 2s 3d. “Full House”: 3 cards with the same number and the remaining 2 cards have the same number. For example: 6d 6h 6s 7c 7s. “Flush”: 5 cards with the same suit but not consecutive numbers. For example: 2h 3h Qh Kh Ah. “Straight”: 5 cards with consecutive numbers but not the same suit. For example: As 2s 3s 4d 5d. “3 of a Kind”: 3 cards with the same number and the remaining 2 cards have different numbers. For example: Td Tc Ts 9s As. “2 Pairs”: 2 pairs of cards with the same number and the remaining card has a different number. For example: 3h 3s 6c 6h 4h. “1 Pair”: 2 cards with the same number and the remaining 3 cards have different numbers. For example: 4d 4c 2c 5d Ac. “High Card”: 5 cards with different, not consecutive numbers and not the same suits. For example: 2c 3d 8c 9h Ah. There are 2 players in the game of five-round show hand. When the game starts, each player will get 25 cards from the dealer. Then, for each round, each player shows a hand by choosing 5 cards from the cards he gets, and two players compare the hands they showed. The player who shows a better kind of hand wins the game. If they show the same kind of hands, they discard the cards they have shown and proceed to the next round. There are at most 5 rounds in a game. If they show the same kind of hands in all of the 5 rounds, the game ends in a tie. Both players play optimally. Your task is to find out the winner and the kind of hands he shows. Input The first line is the number of test cases up to 600. For each test case, there are two lines. The first line is the 25 cards player 1 gets, and the second line is the 25 cards player 2 gets. It is guaranteed that all the 50 cards are different. Output For each test case, output a line containing the winner and the kind of hands he shows. If the game ends in a tie,output “Tie” and the kind of hands both player show. Sample Input 3 2d 2h 3d 3c 4d 4s 5d 6h 7d 7c 8d 8c 9d 9s Td Tc Ts Th Jh Js Qd Qh Kc As Ad 2c 2s 3h 3s 4c 4h 5c 5h 5s 6d 6c 6s 7h 7s 8s 8h 9c 9h Jd Jc Qc Qs Kd Ac Ah 2s 3d 3c 3s 3h 4s 4h 5c 5s 6s 6h 7s 7h 8c 8s Td Th Js Jh Qs Qh Kc Kh Ad As 2d 2h 4d 4c 5d 5h 6d 6c 7d 7c 8d 8h 9d 9c 9s 9h Tc Ts Jd Jc Qd Kd Ks Ac Ah 2d 3d 4d 6d 7d 8d 9d Jd Qd Kd Ad 2c 3c 4c 6c 7c 8c 9c Jc Qc Kc Ac 5h 5s Th 2h 3h 4h 6h 7h 8h 9h Jh Qh Kh Ah 2s 3s 4s 6s 7s 8s 9s Js Qs Ks As 5d Td Tc Sample Output Player 1, Straight Flush Player 2, Straight Flush, 4 of a Kind, Flush, Straight, 1 Pair Tie, Flush, Flush, Flush, Flush, 2 Pairs
- 回答 1 已采纳 我们作业的要求是要52张牌一轮打完后就会结束,每张牌不重复。电脑跟人比扑克牌大小，不分花色， A最大，依次K,Q,J.....有个开始游戏的按钮，大的一方得2分，如果平局各1分。游戏结束会说Game Over。然后再点按钮又开始新的一局。 才刚学不知道怎么写，我是用picture box 加载了图片资源。主要是想知道怎样让52张牌打完一轮后会结束而且不重复。
- 回答 2 已采纳 Java语言编写一个扑克牌发牌的程序，平均将54张牌打乱发给4个人，怎么实现 Java语言编写一个扑克牌发牌的程序，平均将54张牌打乱发给4个人，怎么实现
- 小坑呀的博客 一张扑克牌可用结构类型描述，一副扑克牌的52张牌则是一个结构数组。 1、试编写洗牌函数和供4人玩牌的发牌函数。 2、统计出现同花顺的概率 提示：模拟发牌100000次（这个次数可用#define设置），程序最后统计如下...
- 3年前EasyChill的博客 一、基本概念和术语 数据：是客观事物的符号表示，能够输入到计算机中并...数据结构：是相互之间存在的一种或者多种的特定关系的数据元素的集合，换句话说，数据结构是带结构的数据元素的集合，“结构”，就是指数...
- Dwzb的博客 /*** 这个函数创建一个新的枚举类型，实参对象表示类的每个实例的名字和值* 返回值是一个构造函数，它标识这个新类* 注意，这个构造函数也会抛出异常，不能使用它来创建该类型的新实例* 返回的构造函数包含名/值对的...
- 欧气测不准的博客 数据结构与算法分析 文章目录数据结构与算法分析前言一、数据结构...复习408考研数据结构和学习蓝桥杯的笔记，也有相关的离散数学基础内容记录，本笔记以应试为主 持续更新ing 一、数据结构概述 数据结构相关基本概念
- 4月前神迹小卒的博客 第一章： 数据结构绪论 1.什么是程序：程序 = 数据结构 + 算法 2.逻辑结构&物理结构的区别用法 基本的目标就是将数据及其逻辑关系存储到计算机的内存中 一：逻辑结构: 逻辑结构是指数据对象中数据元素之间...
- 9年前sy0906的博客 而在人工智能领域，依求解问题性质的差异将涉及到各种不同的数据结构，如广义表、集合、搜索树及各种有向图等等。学习数据结构目的是要熟悉一些最常用的数据结构，明确数据结构内在的逻辑关系，知
- 5月前仿生人会梦见电子羊的博客 如何合理地组织数、高效地处理数据，这就是数据结构研究的问题。 1.2 基本概念和术语 1.2.1 数据、数据元素、数据项和数据对象 数据（Data）：是客观事物的符号表示，是所有能输入到计算机中并被计算机程序处理的...
- 1年前#include编程小黑的博客 分配排序则不同，它无需进行关键字的比较，而是利用关键字的结构，通过“分配”和“收集”的办法来实现排序。分配排序可分为箱排序和基数排序两类。 题目描述 给出一组数据，根据由小到大顺序输出。 输入要求： 输入...
- 15年前sanglipeng的博客 数据结构知识 数据结构是计算机软件的一门基础课程,计算机科学各个领域及有关的应用软件都要用到各种数据结构．语言编译要使用栈、散列表及语法树；操作系统中用队列、存储管理表及目录树等；数据库系统运用线性表、...
- 鲍老师的博客 数据结构基础复习09.ppt数据结构考研辅导 基础复习 ...能够对算法进行设计与分析 能够选择合适的数据结构和方法进行问题求解 考研概述 考试形式整卷满分为150分 考试时间为180分钟数据结构占45分 估计用时45 50分钟...
- djd已经存在的博客 Windows XP 系统自带扑克牌资源动态链接库cards.dll逆向分析笔记 使用工具：IDA Pro, Resource Hacker 0. 前言 cards.dll是Windows系统目录下的一个动态链接库，主要提供扑克牌图像及相关操作等资源，以供 ...