65,186
社区成员




// 大乐透
void CLuckyLottoView::OnDltBtnRandom()
{
// TODO: 在此添加命令处理程序代码
int n = 5;
srand((int)time(0));
int front1 = 0;
int front2 = 0;
int front3 = 0;
int front4 = 0;
int front5 = 0;
int back1 = 0;
int back2 = 0;
for (int i = 1; i <= n; ++i)
{
ofstream ofs("ADLT.txt", ofstream::app);
////front////
////1////
front1 = random(35);
////2////
front2 = random(35);
while (front2 == front1)
{
front2 = random(35);
}
////3////
front3 = random(35);
while (front3 == front1 || front3 == front2)
{
front3 = random(35);
}
////4////
front4 = random(35);
while (front4 == front1 || front4 == front2 || front4 == front3)
{
front4 = random(35);
}
////5////
front5 = random(35);
while (front5 == front1 || front5 == front2 || front5 == front3 || front5 == front4)
{
front5 = random(35);
}
////back////
////1////
back1 = random(12);
////2////
back2 = random(12);
while (back2 == back1)
{
back2 = random(12);
}
int front[5] = {front1, front2, front3, front4, front5};
comUse.BubbleSort(front, 5);
CString strFront;
CString strTemp;
for (int k = 0; k < 5; ++k)
{
if (front[k] < 10)
{
strTemp.Format(TEXT("0%d "), front[k]);
}
else
{
strTemp.Format(TEXT("%d "), front[k]);
}
strFront += strTemp;
}
if (back1 > back2)
{
int temp = 0;
temp = back1;
back1 = back2;
back2 = temp;
}
CString strBack;
if (back1 < 10)
{
strTemp.Format(TEXT("0%d "), back1);
}
else
{
strTemp.Format(TEXT("%d "), back1);
}
strBack += strTemp;
if (back2 < 10)
{
strTemp.Format(TEXT("0%d"), back2);
}
else
{
strTemp.Format(TEXT("%d"), back2);
}
strBack += strTemp;
CString strLotto;
strLotto.Format(TEXT("%s%s"), strFront, strBack);
char *charLotto = comUse.CString2char(strLotto);
ofs.write(charLotto, strLotto.GetLength());
charLotto = "\n";
ofs.write(charLotto, 1);
}
}
// 双色球
void CLuckyLottoView::OnSsqBtnRandom()
{
// TODO: 在此添加命令处理程序代码
int n = 5;
srand((int)time(0));
int redBall1 = 0;
int redBall2 = 0;
int redBall3 = 0;
int redBall4 = 0;
int redBall5 = 0;
int redBall6 = 0;
int blueBall = 0;
for (int i = 1; i <= n; ++i)
{
ofstream ofs("ASSQ.txt", ofstream::app);
////red////
////1////
redBall1 = random(33);
////2////
redBall2 = random(33);
while (redBall2 == redBall1)
{
redBall2 = random(33);
}
////3////
redBall3 = random(33);
while (redBall3 == redBall1 || redBall3 == redBall2)
{
redBall3 = random(33);
}
////4////
redBall4 = random(33);
while (redBall4 == redBall1 || redBall4 == redBall2 || redBall4 == redBall3)
{
redBall4 = random(33);
}
////5////
redBall5 = random(33);
while (redBall5 == redBall1 || redBall5 == redBall2 || redBall5 == redBall3 || redBall5 == redBall4)
{
redBall5 = random(33);
}
////6////
redBall6 = random(33);
while (redBall6 == redBall1 || redBall6 == redBall2 || redBall6 == redBall3 || redBall6 == redBall4 || redBall6 == redBall5)
{
redBall6 = random(33);
}
////blue////
////1////
blueBall = random(16);
int redBall[6] = {redBall1, redBall2, redBall3, redBall4, redBall5, redBall6};
comUse.BubbleSort(redBall, 6);
CString strRedBall;
CString strTemp;
for (int k = 0; k < 6; ++k)
{
if (redBall[k] < 10)
{
strTemp.Format(TEXT("0%d "), redBall[k]);
}
else
{
strTemp.Format(TEXT("%d "), redBall[k]);
}
strRedBall += strTemp;
}
CString strBlueBall;
if (blueBall < 10)
{
strTemp.Format(TEXT("0%d "), blueBall);
}
else
{
strTemp.Format(TEXT("%d "), blueBall);
}
strBlueBall += strTemp;
CString strLotto;
strLotto.Format(TEXT("%s%s"), strRedBall, strBlueBall);
char *charLotto = comUse.CString2char(strLotto);
ofs.write(charLotto, strLotto.GetLength());
charLotto = "\n";
ofs.write(charLotto, 1);
}
}