赞
踩
- void BuildRandomSequence(unsigned char * data,const unsigned int len,const unsigned int seed)
- {
- unsigned char temp,xr;
- unsigned int i=0;
- for(i=0; i<len; i++)
- {
- data[i] = i;
- }
- srand(seed);
- for(i=0; i<len; i++)
- {
- xr=rand()%len;
- temp=data[i];
- data[i]=data[xr];
- data[xr]=temp;
- }
- }
BuildRandomSequence()函数可生成一个长度为len,由[0, len-1]的整数组成的不重复序列,序列由种子参数seed决定。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。