2023 HUAWEI OD machine test real test paper B volume [the best way to play cards] C language implementation

Table of contents 

topic

train of thought

Code


topic

There is a deck of poker cards in hand, and each card is scored according to the number of the card (J=11, Q=12, K=13, no king or king)
. For example, if a 2 is played, the score is 2
pairs or 3 cards, and the sum of the card scores is x2. For example, 3 3s are played, and the score is (3+3+3)x2=18. 5 straight cards are played, and the card score is recorded
. The sum is then x2, for example, 34567 Shun, the score is (3+4+5+6+7)x2=50,
4 bombs are played, and the sum of the card points is x3, for example, 4 4s, the score is 4x4x3=
48 Play a deck of cards for the highest score.

Input Description
A deck of cards arranged in order, with a minimum of 1 card and a maximum of 15 cards.
The input of 1-9 is the number 1-9, the input of 10 is the number 0, and the input of JQK is the uppercase letter JQK.
There is no need to consider the situation of illegal input, such as the input characters are not in the [0-9JQK] range or a certain card exceeds 4
output descriptions Remarks
for the highest score The way of playing cards that is not in the scoring rules is not supported, for example, 3 with 1, 4 with 2, and more than 5 cards are not supported

Guess you like

Origin blog.csdn.net/misayaaaaa/article/details/132635502