📄 redball.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections ;
using DataAccessLayer;
namespace cpzh
{
class RedBall
{
private HistoryData awardData; //中奖数据
private OLEDBAccessObj dbObj;
private HistoryAnalyse historyAnalyse;
public struct StatResult //红球统计结果
{
public string CurRedBallNo; //当前红球号码
public int CurValue; //当前期数
public int Average; //平均期数
public int HitAward; //中奖次数
public int Appear; //当前期数出现次数
public int Appear1; //当前期数正负一期出现次数
public int Commend; //推荐指数,
//300期没有出现过大于当前期数 加**
//200期没有出现过大于当前期数 加*
//大于40 加*
//大于60 加**
//300期内出现超过40 加*
//200期内正负两期范围出现超过3次 加*
//200期内正负3期范围出现超过3次 加*
}
public RedBall()
{
awardData = new HistoryData();
this.dbObj = new OLEDBAccessObj();
this.dbObj.ConnectDB();
this.historyAnalyse = new HistoryAnalyse(this.dbObj);
}
#region//获得红球历史中奖分布图
/// <summary>
/// 获得红球历史中奖分布图
/// </summary>
/// <param name="redArray">红球中奖数据ArrayList{期号,中奖号}</param>
/// <returns>返回红球历史中奖分布图ArrayList{id,期号,1,2,3,4,5,6,7,8,9,,,33}</returns>
public static ArrayList GetStatResult(ArrayList redArray)
{
int iAward;
int[] iSum; //中间结果数组
string[][] history; //中奖数据
string[] temp; //中间结果数组
ArrayList alTemp; //中间结果数组
ArrayList filterResult; //预测本期中奖号数组
ArrayList ResultArray; //生成的最终结果数组
string[] redTempArray=new string [6]; //红球数组
iAward = 0;
iSum = new int[33];
alTemp = new ArrayList();
temp = new string[35];
history = new string[redArray.Count][];
filterResult = new ArrayList();
ResultArray = new ArrayList();
redArray.CopyTo(history);
//初始化临时数组
for (int i = 0; i < iSum.Length; i++)
{
iSum[i] = 0;
}
for (int i = history.Length - 1; i > -1; i--)
{
temp = new string[35];
temp[0] = i.ToString();
temp[1] = history[i][0].ToString();
//统一加1操作33个数
for (int j = 0; j < 33; j++)
{
iSum[j] = iSum[j] + 1;
temp[j + 2] = iSum[j].ToString();
}
redTempArray = history[i][1].Split('-');
//把中奖位置置零
for (int k = 0; k < 6; k++)
{
iSum[int.Parse(redTempArray[k].ToString()) - 1] = 0;
temp[int.Parse(redTempArray[k].ToString()) + 1] = "-" + redTempArray[k].ToString();
}
ResultArray.Add(temp);
}
return ResultArray;
}
#endregion
#region//获得红球历史中奖分布图+6位上期统计
/// <summary>
/// 获得红球历史中奖分布图
/// </summary>
/// <param name="redArray">红球中奖数据ArrayList{期号,中奖号}</param>
/// <returns>返回红球历史中奖分布图ArrayList{id,期号,1,2,3,4,5,6,7,8,9,,,33,1,2,3,4,5,6}</returns>
public static ArrayList GetStatResult1(ArrayList redArray)
{
int[] iSum; //中间结果数组
string[][] history; //中奖数据
string[] temp; //中间结果数组{id,期号,1,2,3,4,5,6,7,8,9,,,33,1,2,3,4,5,6}后六位为中奖号上期情况,如连号则为0,否则为多少期未出的期号
ArrayList alTemp; //中间结果数组
ArrayList filterResult; //预测本期中奖号数组
ArrayList ResultArray; //生成的最终结果数组
//int[] filterArray; //预测本期中奖号数组
int iAward; //中奖号码
int iCurAward; //当前期中奖号码
//BlueBall blueBall = new BlueBall(); //蓝球对象
string[] redTempArray = new string[6]; //红球数组
iAward = 0;
iSum = new int[33];
alTemp = new ArrayList();
temp = new string[41];
history = new string[redArray.Count][];
filterResult = new ArrayList();
ResultArray = new ArrayList();
redArray.CopyTo(history);
//初始化临时数组
for (int i = 0; i < iSum.Length; i++)
{
iSum[i] = 0;
}
for (int i = history.Length - 1; i > -1; i--)
{
temp = new string[35];
temp[0] = i.ToString();
temp[1] = history[i][0].ToString();
//统一加1操作33个数
for (int j = 0; j < 33; j++)
{
iSum[j] = iSum[j] + 1;
temp[j + 2] = iSum[j].ToString();
}
redTempArray = history[i][1].Split('-');
//把中奖位置置零
for (int k = 0; k < 6; k++)
{
iSum[int.Parse(redTempArray[k].ToString()) - 1] = 0;
temp[int.Parse(redTempArray[k].ToString()) + 1] = "-" + redTempArray[k].ToString();
}
ResultArray.Add(temp);
}
return ResultArray;
}
#endregion
#region//获得某个红球的出现频率
/// <summary>
/// 获得某个红球的出现频率
/// </summary>
/// <param name="awardDataNum">统计期数</param>
/// <param name="redBallNo">红球号码</param>
/// <returns>返回如:{3,22,1,33,32,43}</returns>
public ArrayList GetRedFrequency(int awardDataNum, int redBallNo)
{
ArrayList tempArray;
ArrayList resultArray; //结果数组
string[][] redBall;
string[] sTemp; //中间临时结果数组,{期号,间隔期数}
int iFrequency; //当前红球出现的次数
int I_SIX=6;
string[] redTempArray = new string[7]; //红球数组
iFrequency = 0;
resultArray = new ArrayList();
tempArray = new ArrayList();
//获得历史中奖数据
tempArray = historyAnalyse.GetRedData(awardDataNum);
redBall = new string[tempArray.Count][];
tempArray.CopyTo(redBall);
for (int i = 0; i < redBall.Length ; i++)
{
string [] redArray=new string [7];
Boolean exist=false;
redArray= redBall[i][1].Split('-');
//判断中奖号中是否存在当前红球
for (int j = 0; j < I_SIX; j++)
{
if (redArray[j].ToString() == redBallNo.ToString())
{
exist = true;
}
}
//如果是则添加到最后结果中,否则累计计数器
if (exist)
{
sTemp = new string[2];
sTemp[0] = redBall[i][0].ToString();
sTemp[1] = iFrequency.ToString();
resultArray.Add(sTemp);
iFrequency = 0;
}
else
{
iFrequency += 1;
}
}
return resultArray;
}
#endregion
#region//获得所有红球的出现频率统计信息
/// <summary>
/// 获得所有红球的出现频率统计信息
/// </summary>
/// <param name="awardDataNum">统计期数</param>
/// <returns>返回所有红球的统计信息{statresult1,statresult2}</returns>
public StatResult[] GetAllRedFrequency(int awardDataNum)
{
int I_SIX=6; //常数6
int I_THIRTY_THREE=33; //常数33
ArrayList statResult; //统计结果对象
ArrayList tempArray; //临时结果数组
ArrayList resultArray; //临时结果数组
string[][] redBall; //临时结果数组
string[] tempConArray; //临时转换数组
int iFrequency; //间隔期数
statResult =new ArrayList ();
tempArray = new ArrayList();
//获得历史中奖数据
tempArray = historyAnalyse.GetRedData(awardDataNum);
redBall = new string[tempArray.Count][];
tempArray.CopyTo(redBall);
for (int redBallNo = 1; redBallNo <= I_THIRTY_THREE; redBallNo++)
{
iFrequency = 0;
resultArray = new ArrayList();
for (int i = 0; i < redBall.Length; i++)
{
string[] redArray = new string[7];
Boolean exist = false;
redArray = redBall[i][1].Split('-');
//判断中奖号中是否存在当前红球
for (int j = 0; j < I_SIX; j++)
{
if (redArray[j].ToString() == redBallNo.ToString())
{
exist = true;
}
}
//如果是则添加到最后结果中,否则累计计数器
if (exist)
{
//sTemp = new string[2];
//sTemp[0] = redBall[i][0].ToString();
//sTemp[1] = iFrequency.ToString();
resultArray.Add(iFrequency.ToString());
iFrequency = 0;
}
else
{
iFrequency += 1;
}
}
//转换数组
tempConArray =new string [resultArray.Count ];
resultArray.CopyTo (tempConArray );
//统计结果
statResult.Add (ConStatResult(tempConArray ,redBallNo ));
}
StatResult[] result = new StatResult[statResult.Count];
statResult.CopyTo(result);
return result;
}
#endregion
#region//转换统计结果
/// <summary>
/// 转换统计结果
/// </summary>
/// <param name="statResult">某个红球的统计信息{2,6,4,0,0,7}</param>
/// <param name="curRedBallNo">当前红球号码</param>
/// <returns>返回统计结果对象statresult</returns>
public StatResult ConStatResult(string[] statResult,int curRedBallNo )
{
int Summation; //总和
StatResult tempResult = new StatResult();
//计算统计信息
Summation = 0;
tempResult.CurRedBallNo = curRedBallNo.ToString();
tempResult.Appear = 0;
tempResult.Appear1 = 0;
tempResult.HitAward = statResult.Length - 1;
tempResult.CurValue = Convert.ToInt32(statResult[0].ToString());
for (int i = 1; i < tempResult.HitAward; i++)
{
int curValue = Convert.ToInt32(statResult[i].ToString());
Summation += curValue;
//当前期数出现次数
if (curValue == tempResult.CurValue )
{
tempResult.Appear += 1;
}
//当前期数正负一期出现次数
if (tempResult.CurValue >= curValue - 1 && tempResult.CurValue <= curValue + 1)
{
tempResult.Appear1 += 1;
}
}
//平均期数
tempResult.Average = Summation / statResult.Length-1;
//推荐指数待写
tempResult.Commend = 0;
return tempResult;
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -