In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces java how to achieve two-color ball machine number generator, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Double color ball numbers 1: 32 do not repeat 6 (sorted well), choose one of 1: 16 (blue number)
Tool class of import java.util.Random;import java.util.Arrays; / / Operand array / * * @ author Administrator * * / public class Lettery {public static void main (String [] args) {for (int I = 0; I < 5; iTunes +) {int [] nos = create (); / / System.out.println (nos); System.out.println (Arrays.toString (nos)) Choose a note * * @ return * / public static int [] create () {int [] nos = new int [7]; Random r = new Random (); LoopI: for (int I = 0; I < 6;) {nos [I] = r.nextInt (32) + 1 / / Mr. Cheng then compares the current number with the previously generated number to find a repeat for (int j = 0; j < I; Jake +) {if (nos [I] = = nos [j]) {/ / System.out.println ("number" + (I + 1) + "number:" + nos [I] + "and" number + (j + 1) + "); continue LoopI } nos [6] = r.nextInt (16) + 1; Arrays.sort (nos,0,6); / / the first 6 bits of a pair of arrays are sorted by return nos;} public static void printArray (int [] arrays) {for (int I = 0; I < arrays.length; iTunes +) {System.out.print (arrays [I] + ",") Thank you for reading this article carefully. I hope the article "how to realize the two-color ball machine number generator with java" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.