一定范围内产生不重复随机数算法

void init(int out[])
{
   
int arr[53];
   
int i,rnd;
   
for(i=0;i<53;i++) arr[i]=i;
   
for(i=52;i>=0;i)
    {
        rnd
= rand()%(i+1);
       
out[i]   = arr[rnd];
        arr[rnd]
= arr[i];
    }
}

This entry was posted on 星期五, 10月 24th, 2008 at 9:16 pm and is filed under 学习/study. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a reply

You must be logged in to post a comment.