双色球算号器

我是个彩民,特别喜欢买双色球。最近看了几种算法,写了一个很简单的双色球的算号器,分享给大家,仅供娱乐,呵呵
package com.tester.luckly;

import java.util.Random;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class DoubleBall {
private Set<Integer> hs;
private static boolean flag = true;

public enum oddOrEven {
Odd, Even
}

public enum aOrBOrC {
A, B, C
}

public static void main(String[] args) {
DoubleBall db = new DoubleBall();
System.out
.println("====================Red Balls============================");
String url1 = "http://map.zhcw.com/ssq//html/h7fenqu_ascstr=20.html";
System.out.println();
System.err.println(url1);
Scanner scanner1 = new Scanner(System.in);
System.out.println("Please select:1.Input your own two numbers");
System.out
.println(" 2.Input the range of the two numbers");
int select = scanner1.nextInt();
if (select == 1) {
flag = false;
} else {
flag = true;
}
System.out.println("Please input two numbers like this: 1 2");
scanner1.nextLine();
String[] str = scanner1.nextLine().split(" ");
Set<Integer> redBall = db.calcRedBall(Integer.parseInt(str[0]), Integer
.parseInt(str[1]));

System.out
.println("====================Blue Ball============================");
String url2 = "http://sports.sohu.com/s2007/0445/s252476794/";
System.out.println();
System.err.println(url2);
Scanner scanner2 = new Scanner(System.in);

System.out.println("1.Please select:" + oddOrEven.Odd + " or "
+ oddOrEven.Even);
String select1 = scanner2.nextLine();

System.out.println("2.Please select:" + aOrBOrC.A + " or " + aOrBOrC.B
+ " or " + aOrBOrC.C);
String select2 = scanner2.nextLine();

int blueBall = db.calcBlueBall(select1, select2);

System.out
.println("====================The Result============================");
System.out.println();
for (int i : redBall) {
System.err.print(i + " ");
}
System.err.println("| " + blueBall);
String url3 = "http://www.bwlc.net/dhtz/";
System.err.println(url3);
}

public Set<Integer> calcRedBall(int begin, int end) {
hs = new TreeSet<Integer>();

/*
* 固定恒码:就是每期都必备的号码,通常为2-3个,如02,13,27。 这2-3个号码长期备选(至少50期)。
*/
hs.add(10);
hs.add(27);

/*
* 边缘捡“胆”:就是在边缘码“05、10、15、20、25、30”及“01、
* 06、11、16、21、26、31”共13个号码中巧妙地捡出胆码。之所以 把边缘码作为“胆”码的一种选取方法,是因为从历史中奖号码来看,
* 几乎每一期都会在具备这种特性的号码中出现2-3个。
*/
int[] array = { 5, 15, 20, 25, 30, 01, 06, 11, 16, 21, 26, 31 };
for (int i = 0; i < 2; i++) {
Random random = new Random();
hs.add(array[random.nextInt(array.length)]);
}

/*
* 重码追邻:在上上期出号的左右选取的上期号码,这话不好理解,现举例说明:双色球2007109期开01 04 07 08 13 14;
* 110期开02 04 07 15 24 28;其中这期的04
* 07,刚好是109期二、三位的重码,那么111期的重码该选取哪个呢?重码追邻就是在110期的04 07 的左右选取,110期04 07
* 的左右是02 15。所以111期的备选号就是02 15 了。实际上111期重码刚好开的是02。重码追邻一般选取2-3个号码。
*/
/* ========= 或者========= */
/* 旺区落“胆”。就是在最近几期热号区选择胆码。比如,如果最近的5期内,在中区12~22出号比较密集,那么就要在这个区域里选取3个胆码。这样选择的理由是热码恒热原理,即号码总是在某个区域相对集中出现。 */
if (flag == true) {
hs.add(begin);
hs.add(end);
} else {
Random random = new Random();
hs.add(begin + random.nextInt(end - begin + 1));
}
/* Luck number! */
while (hs.size() < 6) {
Random random = new Random();
hs.add(1 + random.nextInt(33));
}

return hs;
}

public int calcBlueBall(String select1, String select2) {
int begin = 1;
int end = 16;

if (select2.equals(aOrBOrC.A.toString())) {
begin = 1;
end = 5;
} else if (select2.equals(aOrBOrC.B.toString())) {
begin = 6;
end = 10;
} else {
begin = 11;
end = 16;
}

Random random = new Random();
int blueBall = begin + random.nextInt(end - begin + 1);
if (select1.equals(oddOrEven.Odd.toString())) {
while (blueBall % 2 == 0) {
blueBall = begin + random.nextInt(end - begin + 1);
}
} else {
while (blueBall % 2 == 1) {
blueBall = begin + random.nextInt(end - begin + 1);
}
}

return blueBall;
}
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值