Generating random numbers
Generating random numbers
- Subject: Generating random numbers
- From: Mahaboob <email@hidden>
- Date: Wed, 05 Aug 2009 16:14:08 +0530
- Thread-topic: Generating random numbers
I need to produce 15 random numbers between 1 to 16 without repeating any
number. I used the code like
int i,j;
for(i=0;i<15;i++){
j =random() % 15 +1;
NSLog(@"No: %d => %d \n",i,j);
srandom(time(NULL)+i);
}
But some numbers are repeating.
How can I do it without repeating the numbers?
Thanks in advance
Mahaboob
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden