Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Java Poker Junko

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to realize Java playing cards". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Java Poker Junzi how to achieve" it!

Title

LL was in a good mood today because he went to buy a deck of playing cards and found that there were 2 kings and 2 Xiaowang (a deck of cards was originally 54 ^ _ ^). He randomly drew five cards from them to test his luck to see if he could get Shunzi. If so, he decided to buy a sports lottery ticket. Heh heh! "An of hearts, 3 of spades, Xiao Wang, Da Wang, Fangpian 5", "Oh My God!" Not Shunzi. LL was unhappy. He thought about it and decided that Big / Xiao Wang could be regarded as any number, and An as 1, J was 11, Q was 12, K was 13. The above five cards can be changed into "1 So Lucky, 2, 3, 4, 5" (big and small kings are regarded as 2 and 4, respectively), and "4!". LL decided to buy sports lottery tickets. Now, you are asked to use this card to simulate the above process, and then tell us how lucky LL is. If the card can make up Junzi, output true, otherwise output false. For convenience, you can think of the big and small king as 0.

Analysis.

Is an array, 0 means big and small king, can be toad son, the other minimum is 1, the maximum is 13, to find out whether the given array can form a straight son.

Let's think about a normal Junko, such as 6, 7, 8, 9, 10. The difference between the maximum and minimum values is 4 and cannot be repeated. So we should draw two conclusions. 1, the difference between the maximum value and the minimum value is less than or equal to 4, why is it less than 4, because it is caused by leprosy 0. two。 With the exception of Lianzi 0, the other figures can not be repeated.

So according to the above conditions, we can write the algorithm. Find the minimum and maximum.

How to judge the repetition number? First determine whether it is 0, not 0, store this number as a footer in another array, and count plus 1 to determine whether it is repeated.

Solution public boolean isContinuous (int [] numbers) {

Int count [] = new int [14]

If (numbers==null | | numbers.length

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report