📄 checknew.cpp
字号:
#include "StdAfx.h"
#include "CheckNew.h"
#include "Myfunc.h"
#include "iostream.h"
#include "iomanip.h"
#include "fstream.h"
#include "strstrea.h"
int CCheckNew::GetNewLottary()
{
int M=1,N=33,P=1,Q=16;
int K=7;
int*OneLotta;
OneLotta=new int[K];
bool numok=FALSE;
//srand(1024*(unsigned)time( NULL ));
//GetALottary(M,N, P, Q, 6,1,OneLotta);
/*
int nsum;//sum;
double AllAverage;//AllAverage
int nOdd;
int nEven;//even to odd
int intervals[NUM_RED-1];
int numIn4Zone[4];//numbers in 4 zones;
int recur[5];// recur balls
*/
while(numok==FALSE)
{
numok=TRUE;
GetALottary(M,N, P, Q, 6,1,OneLotta);
//**************在这里开始挑选合适的号码**************************************************
if((OneLotta[0]==0)||(OneLotta[0]==1)||(OneLotta[K-2]==33)) numok=FALSE;
if((OneLotta[K-1]==0)||(OneLotta[K-1]==1)||(OneLotta[K-1]>=16)) numok=FALSE;
}
int temp[7];
for(int i=0;i<NUM_RED;i++)
{
NewLott.RedBall[i]=OneLotta[i];
// New1.RedBall[i]=OneLotta[i];
temp[i]=OneLotta[i];
}
for(i=0;i<NUM_BLUE;i++)
{
NewLott.BlueBall[i]=OneLotta[NUM_RED+i];
temp[i]=OneLotta[NUM_RED+i];
}
//*************挑选结束!*************************************************************
NewLott.GetRedAverage();
NewLott.GetAllAverage();
NewLott.GetIntervals();
NewLott.GetNumIn4Zone();
NewLott.GetRedOdd();
NewLott.GetAllOdd();
NewLott.GetRedSum();
NewLott.GetAllSum();
NewLott.nRedEven=NUM_RED-NewLott.nRedOdd;
NewLott.nAllEven=NUM_RED+NUM_BLUE-NewLott.nAllOdd;
int ZoneMax=0;
for(int k=0;k<NUM_RED;k++)
{
if (NewLott.numIn4Zone[k]>ZoneMax) ZoneMax=NewLott.numIn4Zone[k];
}
if(ZoneMax>4) numok=FALSE;
delete OneLotta;
return(0);
}
int CCheckNew::SetSum(int M,int N)
{
int numok;
numok=1;
NewLott.GetAllSum();
if((NewLott.nAllSum>=M)&&(NewLott.nAllSum<=N)) numok=0;
return(numok);
}
double CCheckNew::SetAllAverage(int M,int N)
{
bool numok;
numok=FALSE;
while(numok==FALSE)
{
NewLott.GetAllAverage();
if((NewLott.AllAverage>=M)&&(NewLott.AllAverage)) numok=TRUE;
else GetNewLottary();
}
return(NewLott.AllAverage);
}
int CCheckNew::SetAllOdd(int M)
{
int numok;
numok=1;
NewLott.GetAllOdd();
if((NewLott.nAllOdd-M)==0) numok=0;
else GetNewLottary();
return(numok);
}
int CCheckNew::SetRedOdd(int M)
{
int numok;
numok=1;
while(numok!=0)
{
NewLott.GetRedOdd();
if((NewLott.nRedOdd-M)==0) numok=0;
else GetNewLottary();
}
return(numok);
}
int CCheckNew::SetNumIn4Zone(int n0,int n1,int n2,int n3)
{
bool numok;
numok=FALSE;
int temp;
while(numok==FALSE)
{
NewLott.GetNumIn4Zone();
temp=(NewLott.numIn4Zone[0]-n0)*(NewLott.numIn4Zone[1]-n1)*(NewLott.numIn4Zone[2]-n2)*(NewLott.numIn4Zone[3]-n3);
if(temp==0) numok=TRUE;
// else GetNewLottary();
}
return(0);
}
int CCheckNew::SetIntervals(int Inter0,int Inter1,int Inter2,int Inter3,int Inter4,int Inter5)
{
bool numok;
numok=FALSE;
int temp;
while(numok==FALSE)
{
NewLott.GetIntervals();
temp=(NewLott.intervals[0]-Inter0)*(NewLott.intervals[1]-Inter1)*(NewLott.intervals[2]-Inter2)*(NewLott.intervals[3]-Inter3)
*(NewLott.intervals[4]-Inter4)*(NewLott.intervals[5]-Inter5);
if(temp==0) numok=TRUE;
else GetNewLottary();
}
return(0);
}
int CCheckNew::CheckIntervals()
{
bool numok;
numok=FALSE;
int t[5],tt,kk[5];
t[0]=NewLott.intervals[0];
t[1]=NewLott.intervals[1];
t[2]=NewLott.intervals[2];
t[3]=NewLott.intervals[3];
t[4]=NewLott.intervals[4];
while(numok==FALSE)
{
for(int i=0;i<4;i++)
{
kk[i]=0;
for(int j=i;j<5;j++)
{
tt=NewLott.intervals[i]-NewLott.intervals[j];
if(tt==0) kk[i]++;
}
}
}
return(0);
}
int CCheckNew::CheckData(int M,CString FileName)
{
int i=0;
int j=0;
CString a;
a=FileName;
a.Format(FileName);
ifstream rgf(a,ios::out);
FILE *fp1;
fp1=fopen("Check_New_Data.txt","w+");
/*
for(i=0;i<M;i++)
{
PastData[i].date=0;
for( j=0;j<NUM_RED;j++)
{
PastData[i].RedBall[j]=0;
}
if(NUM_BLUE==1)
PastData[i].BlueBall[0]=0;
if(NUM_BLUE==2)
{
PastData[i].BlueBall[0]=0;
PastData[i].BlueBall[1]=0;
}
}
*/
for(i=0;i<M;i++)
{
// rgf>>PastData[i].date;
for( j=0;j<NUM_RED;j++)
{
NewData[i].RedBall[j];
if(NewData[i].RedBall[j]==0)
rgf>>NewData[i].RedBall[j];
}
if(NUM_BLUE==1)
rgf>>NewData[i].BlueBall[0];
if(NewData[i].BlueBall[0]==0)
rgf>>NewData[i].BlueBall[0];
if(NUM_BLUE==2)
{
rgf>>NewData[i].BlueBall[0];
rgf>>NewData[i].BlueBall[1];
}
//
NewData[i].GetAllAverage();
NewData[i].GetRedAverage();
NewData[i].GetIntervals();
NewData[i].GetNumIn4Zone();
NewData[i].GetAllOdd();
NewData[i].GetRedOdd();
NewData[i].GetRedSum();
NewData[i].GetAllSum();
NewData[i].nAllEven=NUM_RED+NUM_BLUE-NewData[i].nAllOdd;
NewData[i].nRedEven=NUM_RED-NewData[i].nRedOdd;
fprintf(fp1,"%d %d %d %d %d %d %d\n ",NewData[i].RedBall[0],NewData[i].RedBall[1],
NewData[i].RedBall[2],NewData[i].RedBall[3],NewData[i].RedBall[4],NewData[i].RedBall[5],NewData[i].BlueBall[0]);
fprintf(fp1,"红球总和=%d,总和=%d,红球平均=%f,总平均=%f,红球奇偶比=%d:%d,总奇偶比=%d:%d,间隔%d %d %d %d %d 四个区 %d,%d,%d,%d \n",
NewData[i].nRedSum,NewData[i].nAllSum,NewData[i].RedAverage,NewData[i].AllAverage,NewData[i].nRedOdd,NewData[i].nRedEven,NewData[i].nAllOdd,NewData[i].nAllEven,NewData[i].intervals[0],NewData[i].intervals[1],NewData[i].intervals[2],NewData[i].intervals[3],NewData[i].intervals[4],
NewData[i].numIn4Zone[0], NewData[i].numIn4Zone[1],NewData[i].numIn4Zone[2], NewData[i].numIn4Zone[3]);
}
rgf.close();
fclose(fp1);
// AfxMessageBox("Read data finished!");
// a.Format("red=%d,blue=%d",NUM_RED,NUM_BLUE);
//// AfxMessageBox(a);
return(0);
}
;
CCheckNew::CCheckNew()
{
}
CCheckNew::~CCheckNew()
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -