福利彩票的算法
来源:互联网 发布:一步之遥 知乎 编辑:程序博客网 时间:2024/05/02 01:14
#include<iostream>
#include<stdlib.h>
#include<time.h>
using namespace std;
void main()
{
int array[7];
int temp;
char ch;
do
{
srand(time(0));
for(int i=0;i<7;i++)
{
temp=rand()%35+1;
for(int j=0;j<i;j++)
{
if(temp==array[j])
{
j=i+13;
}
}
if(j>i+6)
{
i--;
continue;
}
else
{
array[i]=temp;
}
}
for(int i=0;i<7;i++)
{
cout<<array[i]<<" ";
}
cout<<endl;
cout<<"是否再次生成(y/n)";
cin>>ch;
}while(ch=='y');
cout<<endl;
}
#include<stdlib.h>
#include<time.h>
using namespace std;
void main()
{
int array[7];
int temp;
char ch;
do
{
srand(time(0));
for(int i=0;i<7;i++)
{
temp=rand()%35+1;
for(int j=0;j<i;j++)
{
if(temp==array[j])
{
j=i+13;
}
}
if(j>i+6)
{
i--;
continue;
}
else
{
array[i]=temp;
}
}
for(int i=0;i<7;i++)
{
cout<<array[i]<<" ";
}
cout<<endl;
cout<<"是否再次生成(y/n)";
cin>>ch;
}while(ch=='y');
cout<<endl;
}
下面这种在控制太可以不停的变换,模拟了抽奖的效果
#include<iostream>
#include<time.h>
#include<stdlib.h>
using namespace std;
void main()
{
int r1,r2,r3,r4,r5,r6,r7;
srand(time(0));
printf("c产生的随即数为: ");
while(1)
{
r1=rand()%35+1;
do
{
r2=rand()%35+1;
}while(r2==r1);
do
{
r3=rand()%35+1;
}while(r3==r1 && r3==r2);
do
{
r4=rand()%35+1;
}while(r4==r1 && r4==r2 && r4==r3);
do
{
r5=rand()%35+1;
}while(r5==r1 && r5==r2 && r5==r3 && r5==r4);
do
{
r6=rand()%35+1;
}while(r6==r1 && r6==r2 && r6==r3 && r6==r4 && r6==r5);
do
{
r7=rand()%35+1;
}while(r7==r1 && r7==r2 && r7==r3 && r7==r4 && r7==r5 && r7==r6);
printf("%2d-%2d-%2d-%2d-%2d-%2d-%2d ",r1,r2,r3,r4,r5,r6,r7);
//降低文字改变速度
for(int i=0;i<99999999;i++)
{}
}
}
#include<time.h>
#include<stdlib.h>
using namespace std;
void main()
{
int r1,r2,r3,r4,r5,r6,r7;
srand(time(0));
printf("c产生的随即数为: ");
while(1)
{
r1=rand()%35+1;
do
{
r2=rand()%35+1;
}while(r2==r1);
do
{
r3=rand()%35+1;
}while(r3==r1 && r3==r2);
do
{
r4=rand()%35+1;
}while(r4==r1 && r4==r2 && r4==r3);
do
{
r5=rand()%35+1;
}while(r5==r1 && r5==r2 && r5==r3 && r5==r4);
do
{
r6=rand()%35+1;
}while(r6==r1 && r6==r2 && r6==r3 && r6==r4 && r6==r5);
do
{
r7=rand()%35+1;
}while(r7==r1 && r7==r2 && r7==r3 && r7==r4 && r7==r5 && r7==r6);
printf("%2d-%2d-%2d-%2d-%2d-%2d-%2d ",r1,r2,r3,r4,r5,r6,r7);
//降低文字改变速度
for(int i=0;i<99999999;i++)
{}
}
}
- 福利彩票的算法
- 福利彩票的真相
- 今晚的福利彩票的中奖号码是
- Matlab计算福利彩票的中奖概率
- 没事闲的做了个简单的福利彩票机选-写的不是很规范
- “双色球”电脑福利彩票投注指南
- 福利彩票幸运号码自动生成器
- 福利彩票选号盘(silverlight5 开源)
- java实现双色球福利彩票系统
- 福利彩票号码生成【js生成随机数】
- 福利彩票36选7模拟程序
- MySQL 福利彩票业务 如何存储毫秒微秒
- [软件发布]福利彩票模拟系统 绿色版 v1.0
- 民政部回应福利彩票被曝黑幕事件:正在调查
- 【算法】算法的艺术
- [算法]算法的乐趣
- [算法]求最大公约数的算法
- 遗传算法的一般算法
- 桃太郎CD到着……
- ova怪奇事件簿
- 少年
- ShootSearch(c#开源搜索)0.1bate补丁
- struts title 使用
- 福利彩票的算法
- 35岁成功人的12条黄金法则
- 2006_10_27炸弹人开发日志
- 重温《明星志愿》
- vs. 2005也可以使用web application project, 如何把asp.net ajax特性加入呢?
- [转贴]Adobe联合高通开发将Flash技术应用于手机[来自:ZDNET & CSDN]
- 全面迎接SVN时代来临
- Wiki在企业信息化应用中崭露头角
- 关于blogspot.com被封