刚学编程,写了个双色球和大乐透的号码预测程序,求指正

ppsharp 2012-08-26 10:10:42
哈哈,其实是号码随机程序。





// 大乐透
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);

}
}



...全文
1005 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
fengyanhui0315 2013-06-22
  • 打赏
  • 举报
回复
不错,不过思路可以换换
随风过境 2013-06-05
  • 打赏
  • 举报
回复
界面挺好看,但是用的随机(伪随机)。只能守号了。
蓝鹰 2013-01-15
  • 打赏
  • 举报
回复
用的vs2010,这好像是功能区界面?
ppsharp 2012-11-16
  • 打赏
  • 举报
回复
引用 2 楼 Corner514 的回复:
刚学编程就有4个三角了~~
这四个三角你知道怎么来的吗? 是我自学C++ Primer的时候,回答了论坛里面一些问题。 回答的都是C++ Primer里面的问题。
ppsharp 2012-11-16
  • 打赏
  • 举报
回复
2个月没登陆CSDN了,都忘了结帖了。
cbzjzsb123 2012-08-28
  • 打赏
  • 举报
回复
最新预测程序:139XXXXXXXX(双色球大佬手机,问他开啥就行,反正他说了算)
czl85025482 2012-08-28
  • 打赏
  • 举报
回复
最新预测程序:139XXXXXXXX(双色球大佬手机,问他开啥就行,反正他说了算)
quwei197874 2012-08-26
  • 打赏
  • 举报
回复
不错。
supersonic0410 2012-08-26
  • 打赏
  • 举报
回复
怎么可能有预测程序。每次开奖都是独立事件,与前面开出的号码毛关系都没有(假定,卖彩票的垃圾不作弊)。

随机程序所依赖的仍然是本机的 伪随机数 生成函数。…… 所以 自娱自乐吧~
nightkids_008 2012-08-26
  • 打赏
  • 举报
回复
我根据一堆的规则写了一个杀号的,不过在linux下面,一般能杀掉一半,错杀一个号的概率 30%左右,有空我也给他弄到MFC,做成界面。
hello_world000 2012-08-26
  • 打赏
  • 举报
回复
程序测试过没?
结果准确性高吗?
xcyl 2012-08-26
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

刚学编程就有4个三角了~~
[/Quote]
我想问的也是这个问题
Corner 2012-08-26
  • 打赏
  • 举报
回复
刚学编程就有4个三角了~~

65,186

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧