随机不同的数
int MyRand ( int nMin, int nMax )
{
if ( nMin > nMax )
{
int nTemp = nMin;
nMin = nMax;
nMax = nTemp;
}
return ( nMin + rand() % ( nMax - nMin + 1 ) );
};
bool great(int a,int b)
{
return a>b;
}
int MyBigRand()
{
return MyRand(0, 9)*100000000 + MyRand(0, 9)*10000000 + MyRand(0, 9)*1000000 + \
MyRand(0, 9)*100000 + MyRand(0, 9)*10000 + MyRand(0, 9)*1000 + \
MyRand(0, 9)*100 + MyRand(0, 9)*10 + MyRand(0, 9)*1 + 1;
};
void getKNum(int k, int n)
{///get k nums in 0~n-1 randomly
for(int i=0; i<n; i++)
{
if((MyBigRand()%(n-i)<k))
{
cout<< i << "\n" ;
k--;
}
}
}