Yeah, you are right. I did my own code and is working well for me. My code is :
srandom(time(NULL)); BOOL val; val = FALSE; array = [[NSMutableArray alloc]initWithCapacity:15]; firstNo = random()%15+1; [array addObject:[NSNumber numberWithInt:firstNo]]; for(i=1;i<15;i++){ firstNo = random()%15+1; for(j=0;j<[array count];j++){ if((firstNo == [[array objectAtIndex:j]intValue] )){ i--; val = TRUE; break; } } if(val){ val = FALSE; continue; } else{ [array addObject:[NSNumber numberWithInt:firstNo]]; } } Thanks On 8/6/09 1:50 PM, "Alastair Houghton" <alast...@alastairs-place.net> wrote: > On 6 Aug 2009, at 05:59, Mahaboob wrote: > >> Thanks. >> It is working well. > > I'll say again, off-list, you probably don't want to use Agha Khan's > code; it generates biased results, which are bad in almost all > applications. Take a look at the Wikipedia article I pointed you at, > here, for (a) an algorithm that works, and (b) some notes on > generating random numbers: > > <http://en.wikipedia.org/wiki/Knuth_shuffle> > > Kind regards, > > Alastair. > > -- > http://alastairs-place.net > > > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com