📄 00047.cpp
字号:
/*
名称编号:00047
实现功能:双色球概率验证器,伪随机数的生成
其实基数只有10,取系统时间作为一个seed,不是真正的33选1型,是10选一型
运行结果:通过
*/
/***************************************************************************/
#include<ctime>
#include <windows.h>
#include<iostream>
using namespace std;
void main(void)
{ int rand_num[600];//600次就相当于100期的数据
int counter[33]={0};
srand((unsigned)time(0));
for(int i=1,j=0;i<601;i++,j++)
{
//Sleep(1);
for(int t=1;t<7;t++)
{
rand_num[j]=rand()%33+1;//35就是控制所产生的数全是33及其以内的数字。
if(rand_num[j]<10) cout<<0;
cout<<rand_num[j]<<" ";
}
cout<<endl;
if(rand_num[j]==1) counter[0]++;
if(rand_num[j]==2) counter[1]++;
if(rand_num[j]==3) counter[2]++;
if(rand_num[j]==4) counter[3]++;
if(rand_num[j]==5) counter[4]++;
if(rand_num[j]==6) counter[5]++;
if(rand_num[j]==7) counter[6]++;
if(rand_num[j]==8) counter[7]++;
if(rand_num[j]==9) counter[8]++;
if(rand_num[j]==10) counter[9]++;
if(rand_num[j]==11) counter[10]++;
if(rand_num[j]==12) counter[11]++;
if(rand_num[j]==13) counter[12]++;
if(rand_num[j]==14) counter[13]++;
if(rand_num[j]==15) counter[14]++;
if(rand_num[j]==16) counter[15]++;
if(rand_num[j]==17) counter[16]++;
if(rand_num[j]==18) counter[17]++;
if(rand_num[j]==19) counter[18]++;
if(rand_num[j]==20) counter[19]++;
if(rand_num[j]==21) counter[20]++;
if(rand_num[j]==22) counter[21]++;
if(rand_num[j]==23) counter[22]++;
if(rand_num[j]==24) counter[23]++;
if(rand_num[j]==25) counter[24]++;
if(rand_num[j]==26) counter[25]++;
if(rand_num[j]==27) counter[26]++;
if(rand_num[j]==28) counter[27]++;
if(rand_num[j]==29) counter[28]++;
if(rand_num[j]==30) counter[29]++;
if(rand_num[j]==31) counter[30]++;
if(rand_num[j]==32) counter[31]++;
if(rand_num[j]==33) counter[32]++;
}
cout<<endl<<"100期双色球模拟摇奖统计结果:"<<endl;
for(int k=0;k<33;k++)
{
if(k<9) cout<<0;
cout<<k+1<<" "<<counter[k];
for(int m=0;m<counter[k];m++) {cout<<"*";}
cout<<endl;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -