一、算法介绍
本博文主要写了彩票走势图中的遗漏值、出现总次数、平均遗漏值、最大遗漏值、最大连出值的计算逻辑。
二、图文简介
[这是XX网双色球的彩票走势图,博主这里是将彩票数据分区展示,以双色球为例,分了五个区域,本博文中的遗漏值是按照期数的降序排列计算的如下图]
三、工具类简介(请仔细看完工具类简介)
彩票走势图的工具类**LotteryTrend**中将彩票的名称彩票的id,及其对应的数字域数据域id,每个区域的起始数字,每个区域的长度等数据按照顺序一一对应定义。另一个工具类**MissValue**就是彩票遗漏值的工具类,里面是具体的**彩票遗漏值、出现总次数、平均遗漏值、最大遗漏值、最大连出值**的计算方法,博主将开奖位置的遗漏值置为0,返给前端的。下面是这几个名词的定义:
**彩票遗漏值**:自上期开出到本期间隔的期数。
**出现总次数**:当前选定的彩票期数区间内该球的出现总次数。
**平均遗漏值**:平均遗漏值计算公式:总期数除以出现的总次数,如果总次数为0,该值为0;如果除不尽将计算结果向下取整。
**最大遗漏值**:历史开奖以来该球连续不出现的最大值,即为距离上次出现的间隔数的最大值。
**最大连出值**:**博主写的是选定期数内连续出现的最大值,与右图不符合**.
四、返回给前端的json数据
五、代码块
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
/**
* 彩票走势图工具类
* @author Administrator
*
*/
public class LotteryTrend {
//所有彩票名称数组
public static final String[] titleArray={
"超级大乐透","七星彩","排列三","排列五","双色球","福彩3D","江西11选5","11运夺金","广东11选5","上海11选5","浙江11选5","七乐彩","重庆时时彩","胜负彩","安徽快三","湖北快三","吉林快三","江苏快三","江苏11选5","浙江12选5"};
//彩票的id数组
public static final String[] lotteryidArray={
"19","18","2","13","16","1","9","8","10","24","27","17","3","71","32","33","34","35","28","22"};
//每种彩票的区域或者数字域
public static final String[][] headArray={
{
"红一区","红二区","红三区","后区"},{
"第七位","第六位","第五位","第四位","第三位","第二位","第一位"},{
"百位","十位","个位"},
{
"万位","千位","百位","十位","个位"},{
"红一区","红二区","红三区","篮球"},{
"百位","十位","个位"},
{
"万位","千位","百位","十位","个位"},{
"万位","千位","百位","十位","个位"},{
"万位","千位","百位","十位","个位"},
{
"万位","千位","百位","十位","个位"},{
"万位","千位","百位","十位","个位"},{
"一区","二区","三区"},
{
"万位","千位","百位","十位","个位"},{
"3","1","0"},{
"百位","十位","个位"},
{
"百位","十位","个位"},{
"百位","十位","个位"},{
"百位","十位","个位"},
{
"万位","千位","百位","十位","个位"},{
"万位","千位","百位","十位","个位"}};
//区域或者数字域的id
public static final String[][] idxArray ={
{
"area1","area2","area3","back"},{
"num_info7","num_info6","num_info5","num_info4","num_info3","num_info2","num_info1"},{
"num_info3","num_info2","num_info1"},
{
"num_info5","num_info4","num_info3","num_info2","num_info1"},{
"area1","area2","area3","num_info7"},{
"num_info3","num_info2","num_info1"},
{
"num_info5","num_info4","num_info3","num_info2","num_info1"},{
"num_info5","num_info4","num_info3","num_info2","num_info1"},{
"num_info5",
"num_info4","num_info3","num_info2","num_info1"},{
"num_info5","num_info4","num_info3","num_info2","num_info1"},{
"num_info5","num_info4","num_info3","num_info2","num_info1"},
{
"area1","area2","area3"},{
"num_info5","num_info4","num_info3","num_info2","num_info1"},{
"3","1"</