⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lottery.cpp

📁 产生随机六各数字,在1~49各数字之间,每次产生皆不相同
💻 CPP
字号:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>

#define PRF_MAX  0x00FF

void main()
{
	unsigned int x;
	int i;
	int rand_seed;
	
	clock_t t;
	
	int temp,num;

	i=0;
	
	srand(temp+num+rand());
    temp=rand();
	printf("temp:%d\n",temp);
	srand(time(NULL)+rand());
	temp=rand();
    t=clock();
	printf("first clock:%ld\n",t);
	
	do{
		//do{}while(rand()!=temp);
	}while(rand()!=temp);
	t=clock();
	printf("second clock:%ld\n",t);

	printf("time1:%ld\n",time(NULL));

	rand_seed=rand_seed+temp+num+t;
	
	
	while(i<6) 
	{
//	        temp=rand()%(6-i+1);

/*			srand(time(NULL)+clock()+rand_seed);

			for(num=0;num<temp;num++)
	        {		
		      x=(( 1.0/(RAND_MAX) )*rand() )*49; //value returned froem rand():0~RAND_MAX
			  i++;
			  printf("c:%d\n",x);
			}
*/
//	        temp=rand()%(6-i+1);
//	        for(num=0;num<temp;num++)
//	        { //printf("rand_seed1:%#x\n",rand_seed);
//				do{
				rand_seed = ((long)rand_seed + 56791 )*13579;
				//printf("rand_seed2:%#x\n",rand_seed);
				x=(( 1.0/(0xFF) )*(rand_seed & 0xFF) )*49;
//				}while(x>49);
				i++;
			  printf("net:%d\n",x);
//	        }
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -