本文主要是介绍彩票开奖号码分析:同尾号,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1同尾号
同尾号算法
源代码
…
java.util.Arrays.sort(sortNum);
List<String> numberLst = java.util.Arrays.asList(sortNum);//数组转化成List
StringBuilder sb = new StringBuilder();//
List<String> lst = new ArrayList<String>();
for (int i = 0; i < numberLst.size() - 1;) {
int count = 0;
for (int j = i + 1; j < numberLst.size(); j++) {
if (count == 0
&& Integer.parseInt(numberLst.get(i)) % 10 == Integer
.parseInt(numberLst.get(j)) % 10) {
sb.append(numberLst.get(i) + " " + numberLst.get(j));
count++;
} else if (Integer.parseInt(numberLst.get(i)) % 10 == Integer
.parseInt(numberLst.get(j)) % 10) {
sb.append(" " + numberLst.get(j));
}
}
if (StringUtil.hasText(sb.toString())) {
lst.add(sb.toString());
}
List<String> newArr = new ArrayList<String>();
// 构造新数组
for (int n = 0; n < numberLst.size(); n++) {
if (!sb.toString().contains(numberLst.get(n))) {
newArr.add(numberLst.get(n));
}
}
if (newArr.size() > 0 && newArr.size() < numberLst.size()) {
numberLst = new ArrayList<String>(newArr);
i = 0;
} else {
i++;
}
sb = new StringBuilder();
}
…
解释:
举例[29X7]
| ||
01 02 11 12 21 22 07 | ||
外层第一次循环后List值[01 11 21]一个元素 | 余下的号码成新数组 [02 12 22 07] | i=0 |
外层第二次循环后List值[01 11 21,02 12 22]两个元素 | 余下的号码成新数组[07] | i=0 |
第三次循环 |
| i < numberLst.size() – 1不成立,跳出循环 |
首先为字符串数组升序排序。
内层循环,数组中第一个元素模10后与剩下的每个元素模10后相比较,若能够相等且count(记录一组有几个元素)==0两个元素用空格字符链接后记入StringBuilder中,count++ 若count!=0则将该次循环中被比较元素追加到StringBuilder中。完成构造一组同尾号的字符串。
添加到List中,把余下的元素构造到一个新的List中,如果List中元素个数大于0并且小于开奖号码元素个数,则将numberLst赋值为新数组,且i=0,若newArr.size()==0需要i++,跳出循环,如果newArr.size()==开奖号码最初数组的元素个数,说明没有元素和该次外层循环的数组第一个元素同尾,需要进入下次循环。设置i++;
种类 | 彩种 | 用例 | 结果 |
Area5NumCountStat | DLT | 03,07,20,33,35,04,07 | 2,0,1,0,2 |
Area3NumCountStat | DLT | 03,07,20,33,35,04,07 | 2,1,2 |
29X7 | 03,06,09,11,12,17,29,21 | 3,3,2 | |
Area7NumCountStat | DLT | 03,07,20,33,35,04,07 | 1,1,0,1,0,0,2 |
Area4NumCountStat | 20X5 | 07,09,14,19,20 | 0,2,1,2 |
SeriesNumExtStat [开奖号码大小分布] |
DLT | 03,07,20,33,35,04,07 | “” |
03,07,20,21,35,04,07 | 20 21 | ||
03,04,20,21,35,04,07 | 03 04,20 21 | ||
03,04,27,28,29,04,07 | 03 04,27 28 29 | ||
03,08,27,28,29,04,07 | 27 28 29 | ||
29X7 | 03,08,15,27,28,29,22 | 27 28 29 | |
03,04,15,27,28,29,22 | 03 04,27 28 | ||
03,04,15,16,28,29,22 | 03 04,15 16,28 29 | ||
17,18,19,20,21,22,23 | 17 18 19 20 21 22 23 | ||
03,05,15,17,24,29,22 | “” | ||
20X5 | 03,05,15,17,20 | “” | |
03,04,15,17,20 | 03 04 | ||
03,04,05,17,20 | 03 04 05 | ||
03,04,05,06,20 | 03 04 05 06 | ||
03,04,05,06,07 | 03 04 05 06 07 | ||
07,08,12,17,18 | 07 08,17 18 | ||
07,08,12,13,18 | 07 08,12 13 | ||
SameEndDigitalStat |
DLT | 03,07,20,33,35,04,07 | 03 33 |
03,07,17,33,35,04,07 | 03 33,07 17 | ||
03,07,17,23,33,04,07 | 03 23 33,07 17,23 33 发生错误 | ||
03,07,17,23,33,04,07 | 03 23 33,07 17 | ||
03,07,16,24,34,04,07 | “” | ||
29X7 | 01,02,11,12,21,22,07 | 01 11 21,02 12 22 | |
03,06,09,11,12,17,29,21 | 09 29,11 21 | ||
03,06,09,11,12,17,28,20 | “” | ||
03,06,09,13,16,23,28,20 | 03 13 23,06 16 | ||
03,06,09,13,14,23,28,20 | 03 13 23 | ||
20X5 | 03,06,09,13,20 | 03 13 | |
03,06,09,13,19 | 03 13,09 19 | ||
03,06,08,14,19 | “” |
这篇关于彩票开奖号码分析:同尾号的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!