例如有一排号码是 01 02 03 05 06 07 08
固定为7位 现在是有3个数连号 和4个数连号
就取连好数多的 4个数连好
以下我写的不知哪里有问题?麻烦提点一下!
int[] number_Series_Amount = new int[4] { 0, 0, 0, 0 };//4种连号个数类型统计
int temp_Series_Number=0;//上个号 用于比较
int temp_Series_Sum=0;//连号数累计
int temp_Series_Max = 0;//最大连号数
int[] Series_Type = new int[4] { 2, 3, 4, 5 };//4种连号个数类型 for (int i = 0; i < mdbCount; i++)
{
string[] strListArr = ds.Tables["cp"].Rows[i]["开奖号码"].ToString().Split(new char[] { ':' });
for (int j = 0; j < 7; j++)
{
if (j > 0)
{
if ((temp_Series_Number - Convert.ToInt32(strListArr[j]) == 1) || (temp_Series_Number - Convert.ToInt32(strListArr[j]) == -1))
{
temp_Series_Sum += 1;
}
else
{
if (temp_Series_Sum >= temp_Series_Max)
{
temp_Series_Max = temp_Series_Sum;//取连号最大
}
else
{
if (temp_Series_Sum >= 2)
{
temp_Series_Max = temp_Series_Sum;//如果有 取最低2个连号
}
}
temp_Series_Sum = 0;//没连上就清空
}
}
temp_Series_Number = Convert.ToInt32(strListArr[j]);//记录上个号码 用来比较 if (j == 6)
{
for (int s = 3; s >= 0; s--)//从高到低比较
{
if (Series_Type[s] == temp_Series_Max)
{
number_Series_Amount[s] += 1; ;//对应连号个数类型累加
temp_Series_Sum = 0;
temp_Series_Max = 0;
}
}
}
}
固定为7位 现在是有3个数连号 和4个数连号
就取连好数多的 4个数连好
以下我写的不知哪里有问题?麻烦提点一下!
int[] number_Series_Amount = new int[4] { 0, 0, 0, 0 };//4种连号个数类型统计
int temp_Series_Number=0;//上个号 用于比较
int temp_Series_Sum=0;//连号数累计
int temp_Series_Max = 0;//最大连号数
int[] Series_Type = new int[4] { 2, 3, 4, 5 };//4种连号个数类型 for (int i = 0; i < mdbCount; i++)
{
string[] strListArr = ds.Tables["cp"].Rows[i]["开奖号码"].ToString().Split(new char[] { ':' });
for (int j = 0; j < 7; j++)
{
if (j > 0)
{
if ((temp_Series_Number - Convert.ToInt32(strListArr[j]) == 1) || (temp_Series_Number - Convert.ToInt32(strListArr[j]) == -1))
{
temp_Series_Sum += 1;
}
else
{
if (temp_Series_Sum >= temp_Series_Max)
{
temp_Series_Max = temp_Series_Sum;//取连号最大
}
else
{
if (temp_Series_Sum >= 2)
{
temp_Series_Max = temp_Series_Sum;//如果有 取最低2个连号
}
}
temp_Series_Sum = 0;//没连上就清空
}
}
temp_Series_Number = Convert.ToInt32(strListArr[j]);//记录上个号码 用来比较 if (j == 6)
{
for (int s = 3; s >= 0; s--)//从高到低比较
{
if (Series_Type[s] == temp_Series_Max)
{
number_Series_Amount[s] += 1; ;//对应连号个数类型累加
temp_Series_Sum = 0;
temp_Series_Max = 0;
}
}
}
}
{
if (j > 0)
{
if (temp_Series_Number+1==Convert.ToInt32(strListArr[j]))
{
temp_Series_Sum += 1;
temp_Series_Max = temp_Series_Sum;
}
else
{
if (temp_Series_Sum >= temp_Series_Max)
{
temp_Series_Max = temp_Series_Sum;
}
else
{
if (temp_Series_Sum >= 2)
{
temp_Series_Max = temp_Series_Sum;
}
}
temp_Series_Sum = 0;//没连上就清空
}
}
temp_Series_Number = Convert.ToInt32(strListArr[j]);//记录上个号码 用来比较 if (j == 6)
{
for (int s = 3; s >= 0; s--)//从高到低比较
{
if (Series_Type[s] == temp_Series_Max)
{
number_Series_Amount[s] += 1; ;//对应连号个数类型累加
temp_Series_Sum = 0;
temp_Series_Max = 0;
}
}
}
}
public List<int[]> GetSeriate(int[] array)
{
Array.Sort(array);
List<int[]> result = new List<int[]>();
bool isSeriate = false;
List<int> list = new List<int>();
for (int i = 0; i < array.Length; i++)
{
if (i != array.Length - 1 && array[i + 1] - array[i] == 1)
{
if (!isSeriate)
list.Add(array[i]);
list.Add(array[i + 1]);
isSeriate = true;
}
else
if (isSeriate)
{
result.Add(list.ToArray());
list.Clear();
isSeriate = false;
}
}
return result;
}
int GetMaxCount(int[] nums)
{
int tempCount=1;
int tempNum=nums[0];
int maxCount=0;
foreach(int n in nums)
{
if(n==tempNum+1)
{
tempCount++;
}
else
{
if(tempCount>maxCount) maxCount=tempCount;
tempCount=1;
}
tempNum=n; }
return maxCount;
}
{
maxCount = tempCount;
}