产生不重复序列的范围随机数

#include < stdlib.h >
#include
< time.h >

#include
< iostream.h >
void  main()
{
    srand( (unsigned)time( NULL ) );   //以系统时间作种子,就不会每次都产生一样的序列了
    double temp=double(rand()%4000+3000)/10000.0//调节精度
    temp=temp<0.5?(temp-0.2):(temp+0.2);            //调节范围
    //**temp∈(0.1000,0.3000) ∪ (0.7000,0.9000)
    cout<<temp<<endl;
}

你可能感兴趣的:(随机数)