`
liuxin15571745
  • 浏览: 11023 次
  • 性别: Icon_minigender_1
  • 来自: 广州
最近访客 更多访客>>
社区版块
存档分类

双色球开奖机(纯娱乐)

阅读更多
    最近和朋友一起在玩双色球,感觉每期买一注号码等待开奖的感觉非常不错,有个期盼.
可是每次购买选号码时就犯难了,这个会出,那个不会出,结果总是难以下手(娱乐而已,非专业).
    咱们是弄计算机的,所以还是自己弄个程序来方便(双色就是计算机在控制,只是有规律,咱无法知晓他内部算法).
    听相关人事说双色球是有规律的,可我不懂啥规律..为了让自己在购买填号码时不那么为难,编写了个简单的程序(听天由命).下面是程序所有代码:

package com.lx.Two;
import java.util.*;
/**
* 双色球开奖机
*/
public class RandomTwo {

public static Random rand=new Random(System.currentTimeMillis());

public static Random rand2=new Random(System.currentTimeMillis());
/** 
    * @param h 
    * @return 
    * 实现对map按照value升序排序 
    */ 
   @SuppressWarnings("unchecked")  
   public static Map.Entry[] getSortedHashtableByValue(Map h) {  
       Set set = h.entrySet();  
       Map.Entry[] entries = (Map.Entry[]) set.toArray(new Map.Entry[set  
               .size()]);  
       Arrays.sort(entries, new Comparator() {  
           public int compare(Object arg0, Object arg1) {  
               Long key1 = Long.valueOf(((Map.Entry) arg0).getValue().toString());  
               Long key2 = Long.valueOf(((Map.Entry) arg1).getValue().toString());  
               return key1.compareTo(key2);  
           }  
       });  
 
       return entries;  
   }
  
public static void main(String[] args) {
Map map=new HashMap();
Map map2=new HashMap();
for(int i=0;i<rand2.nextInt(2401)+2401;i++){
int num=rand.nextInt(33)+1; //1-33的随即数
int num1=rand.nextInt(16)+1; //1-16的随即数
if(map.containsKey(num))
map.put(num, Integer.parseInt(map.get(num).toString())+1);
else
map.put(num, new Integer(1));
if(map2.containsKey(num1))
map2.put(num1, Integer.parseInt(map2.get(num1).toString())+1);
else
map2.put(num1, new Integer(1));
}

Map.Entry[] entry=getSortedHashtableByValue(map);
System.out.print("红色球号码为:");
for(int i=entry.length-6;i<entry.length;i++){
System.out.print(entry[i].getKey()+" ");
}
int maxValue=0;
String maxKey=null;
Iterator it = map2.entrySet().iterator();
        for(int i=0;i<map2.size();i++){
            Map.Entry entry2 =(Map.Entry)it.next();
            int value = Integer.parseInt(entry2.getValue().toString());
            if(value > maxValue){
                maxValue = value;
                maxKey = entry2.getKey().toString();
            }
        }
        System.out.println("");
        System.out.println("蓝色球号码为:"+maxKey);

      
}
}


----------------------

红色球号码为:5 18 9 24 3 13
蓝色球号码为:6
--------------------------
各位,纯娱乐而已...建个记事本直接将代码复制上去就OK(类名:RandomTwo)
如有对双色有研究的同学,请留言.大家一起中500万.!




1
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics